1 . Open Eclipse .
2. Create a new Java project. Select "File -> New -> Java Project" from the toolbar, and the "New Java Project" wizard starts.

3. Give the project a name, and choose your preferences on Java version and project organization.
In this example the project is called "Get Location demo Client",
The default values are used for all other selections in this example.
4. Push "Finish" to continue and close the wizard. The project is created, and you can continue to start adding content to your project.
5. Select your project, push the right mouse button and then select "New -> Other" on the toolbar, to start the New wizard.

6. Select Web Service Client from the New menu, and push the "Next" button. The Web Service Client wizard starts.
Here you choose the Web Service location (WSDL file) that we are creating a client for, and the type of client (Java proxy).

7. Push the "Browse" button and the Select Service Implementation wizard starts.

8. Type in the address to the WSDL file,
The tool validates the WSDL file, when the address is fully entered.
The current version of WSDL file and validation tool shows a warning message.
Push "OK" to return to the Web Service Client wizard.
9. Slide the slider down to only create a client, and push the "Finish" button.
The tool creates the stubs and skeletons required to invoke the service.
10. After Clicking on finish you may find four interfaces generated in your workspace.
like below

The next step is to create the code that invokes the service.
10. Add a new Java class, containing a main method. Select your project, and then select "New -> Java" class on the toolbar, to start the New Java Class wizard.

Here actually my Processing Order interface implements one method placeOrder which accepts two arguements... and returns the response
I implement the client in the java class as follows...
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.ws.WebServiceRef;
@WebServiceRef(wsdlLocation="http://localhost:8086/Order_WS/services/ProcessingOrder?wsdl")
public class MyTestClient {
//String url = "http://localhost:8086/Order_WS/services/ProcessingOrder?wsdl";
QName qname = new QName("http://mss.org", "placeOrder");
public static void main(String[] args) throws ServiceException, RemoteException {
ProcessingOrderServiceLocator pol=new ProcessingOrderServiceLocator();
ProcessingOrder po=(ProcessingOrder) pol.getPort(ProcessingOrder.class);
int res=po.placeOrder("137","hiiiieeee");
System.out.println(res);
}
}
Run the MyTestClient class then you will get the response from the Webservice.
2. Create a new Java project. Select "File -> New -> Java Project" from the toolbar, and the "New Java Project" wizard starts.
4. Push "Finish" to continue and close the wizard. The project is created, and you can continue to start adding content to your project.
5. Select your project, push the right mouse button and then select "New -> Other" on the toolbar, to start the New wizard.
10. After Clicking on finish you may find four interfaces generated in your workspace.
like below
The next step is to create the code that invokes the service.
10. Add a new Java class, containing a main method. Select your project, and then select "New -> Java" class on the toolbar, to start the New Java Class wizard.
Here actually my Processing Order interface implements one method placeOrder which accepts two arguements... and returns the response
I implement the client in the java class as follows...
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import javax.xml.ws.WebServiceRef;
@WebServiceRef(wsdlLocation="http://localhost:8086/Order_WS/services/ProcessingOrder?wsdl")
public class MyTestClient {
//String url = "http://localhost:8086/Order_WS/services/ProcessingOrder?wsdl";
QName qname = new QName("http://mss.org", "placeOrder");
public static void main(String[] args) throws ServiceException, RemoteException {
ProcessingOrderServiceLocator pol=new ProcessingOrderServiceLocator();
ProcessingOrder po=(ProcessingOrder) pol.getPort(ProcessingOrder.class);
int res=po.placeOrder("137","hiiiieeee");
System.out.println(res);
}
}
Run the MyTestClient class then you will get the response from the Webservice.
No comments:
Post a Comment