Java – How To Use WSDL Url

glassfishjavanetbeansweb serviceswsdl

I wrote a java web service on Netbeans 6.9.1 and deployed on GlassFish 3.0.1
I have a wsdl url like this "http://localhost:8080/web2/service2Service?wsdl".
How can I use this url to access this web service from another java application.
Thanks

Best Answer

You need to generate some Java that represents the client's view of the Web Service and then invoke that Java. Here's an article which explains some of the detail.

Generating client from WSDL in Eclipse

The general idea is that you generate some Java classes from the WSDL. Those classes act as a proxy for the service you want to call. Your java invokes methods on the proxy objects, the generated code creates the appropriate SOAP messages, sends the HTTP request, interprets the response and your code just sees a Java result.

I just use the tooling built into Eclipse, but you will also find other suitable generators, for example in Apache's Axis