• Entries (RSS)
  • Comments (RSS)

Invoking a web service using web service proxy client

Posted by | Posted in Web service, WebSphere | Posted on 15-09-2008

Tagged Under : , , ,

Invoking a web service using web service proxy client

Yesterday I got a comment on my post “Generating a web service proxy client” asking how do we invoke or test this web service using the webservice proxy client. So I thought of writing a post of how to use the generated proxy client to call a webservice. Here I am going to create a simple JSP file that is going to use the webservice proxy client to call or invoke the Hello World web service running in WebSphere.

Before you start, please make sure that you have generated the web service client as mentioned in Generate web service proxy client in java. If you do not have the Hello World web service running in your server, follow the tutorial at Creating a Hello World web service using RAD.

While generating the webservice proxy client I generated the Java files using no wrapped style.

One we have the java proxy files generated we can see some files named XXXProxy.java, XXX.java, XXXService.java, XXXServiceInformation.java, XXXServiceLocator.java etc in our workspace. Now create a new jsp file for calling the web service. Add the following code to invoke the Hello World webservice using our web service proxy client.

	com.test.HelloWorldProxy proxy = new com.test.HelloWorldProxy();
        String name = proxy.sayHello("Albin Joseph");

If everything works fine, we would see a ‘Hello Albin Joseph’ as the output in your console.

Our Hello World service was exposing a sayHello method as a webservice. The HelloWorldProxy class is the proxy client class for our webservice. If we are not setting the end point url (the url of the webservice), our proxy client would take the default one present in the wsdl file.


Read More

Post a Comment