If you saw my post on 16th of September on creating a web service, you must have realized how easy it is. You can find a lot of information on creating web services but it is hard to find good information on how to create a client to consume the services. In this post I will detail how to do that.
- Before we start modify EchoImpl.java in web service provider project to below
// START SNIPPET: echo
package org.codehaus.xfire.spring.example;
/**
* Provides a default implementation of the echo service interface.
*/
public class EchoImpl implements Echo
{
public String echo(String in)
{
String test = in + “: SOA test is successful”;
return test;
}
}
// END SNIPPET: echo
1. Download and install xFire plugin for Eclipse.
2. From client application (Service consumer application), Generate java classes with WSDL we generated from 16th post. You will get around 6 to 7 classes including endpoint interface class which is abstract interface for service provider's end point, generated stub class which is an implementation of generated endpoint interface and service class (looks like Echoclient.java)
3. Now all we to do is retrieve PortType from service and call the method.
In our case, it will be like
EchoClient service = new EchoClient();
EchoPortType ept = service.getEchoPortType();
String test = ept.bounce(“Hello World”);