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”);
1 comment:
This article is really great, I was trying to find out about how to generate the client code by just having the WSDL of a service.
It worked for me, But have few more questions like does this also has the serverside stubs, I meant what files should I package and sent it to java client.
Thanks,
Padmanabha
Post a Comment