I have created the wsdl successfully .Its url is "http://:/aebis/HelpdeskWebserviceImpl?wsdl". Now I want to use this url to call the function in jsp.I am using Jboss as server. Please suggest if any one can help. Thanks in advance.
-
1Is there a reason, you need it done within a JSP? If you have the chance to use recent technology, don't use JSPs any more. What you need is a client for your web service, for example generated by the wsimport tool from JDK, which then can be used for example by a JSF page. – Alexander Rühl Apr 02 '14 at 12:47
-
how to use wsimport tool in web aaplication. – user3489236 Apr 03 '14 at 09:24
-
https://www.eclipse.org/webtools/jst/components/ws/1.5/tutorials/WebServiceClient/WebServiceClient.html – Leo Apr 03 '14 at 13:06
2 Answers
Here is a 5-minute example using eclipse
I am gonna use this WSDL to demonstrate
http://www.webservicex.net/ConvertAcceleration.asmx?WSDL
Create a dynamic java project for your JSPs
Create your JSP and some backend java class
your JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%= new myweb.MyClass().getResult() %>
</body>
</html>
and
package myweb;
public class MyClass {
public String getResult(){
return null;
}
public static void main(String[] args) {
MyClass c = new MyClass();
System.out.println(c.getResult());
}
}
Now create the WS client. Click on/select the project
right click and create a new Web Service Client from the given WSDL
Change MyClass to call the web service (you can test first using the class main too)
package myweb;
import java.rmi.RemoteException;
import NET.webserviceX.www.AccelerationUnitSoap;
import NET.webserviceX.www.AccelerationUnitSoapProxy;
import NET.webserviceX.www.Accelerations;
public class MyClass {
public String getResult() throws RemoteException {
AccelerationUnitSoap a = new AccelerationUnitSoapProxy();
Accelerations x = Accelerations.decimeterPersquaresecond;
Accelerations y = Accelerations.centimeterPersquaresecond;
Object z = a.changeAccelerationUnit(1, x, y);
return z.toString();
}
public static void main(String[] args) throws RemoteException {
MyClass c = new MyClass();
System.out.println(c.getResult());
}
}
Add the web app to your server (if there's one. If there isn't, create a new server)
Clear the server (forcing it to refresh the app) and start it
And here it is.

- 6,480
- 4
- 37
- 52
The wsimport tool is part of the JDK and generates "portable artifacts" from a wsdl. That gives you classes to use easily for communicating with the web service without the need of doing the boilerplate code yourself.
But I feel that you may need some more background beforehand, to get a better understanding how to use JAX-RS web services or implement a state-of-the-art web application with JSF, so my advice is to consult the Java EE 7 tutorial for those two (chapter 28 and 7).

- 6,769
- 9
- 53
- 96