Consuming the Webservices

Step 1:  Select the HelloService.java and right click on it New-->other
WebService-->WebServiceClient-->Next












Step 2: Enter the service definition this will be the wsdl url for ex:
"http://localhost:8080/TestServices/services/HelloService?wsdl".And you have to select start client by sliding the bar towards up.Finally in the configuration you need to select the tomcatserver,webservice runtime and then click next








and

click finish.The stub and callbackHandler classes are automatically generated for you as shown below.
















Step :3  Create a new class HelloServiceClient.java under com.client to access the service. Here stub is a proxy class, we don't invoke the webservice directly, we will invoke stub class instead and stub class will talk to the service.














Step 4: Here in the client we have to create a stub class object to invoke the service. We have to pass the endpoint into the stub class.We should create an object for the method we are calling and set parameters accordingly.Finally response object will return the response of the service.
Right click on the client -->Run As Java Application and you can finally see the out put.