Java webservice standalone client

I am new to webservices in general. I am trying to write a standalone Java client that can get a response from a web service.

I tried to find SO and Google, but now I have become more confused. Below are the links that I have examined in detail.

I have a url: http://api.something.com/remote/wsdl/SomeEncryptedText

I also have a SOAP request:

<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Body> <AuthUsername>someName@someWhere.com</AuthUsername> <AuthPassword>mypassword</AuthPassword> <Sid>12121</Sid> <DynamicProductFeedsRequest xmlns="http://api.something.com/remote/SomeEncryptedText"> </DynamicProductFeedsRequest> </soap12:Body> </soap12:Envelope> 

With this, can I write a standalone Java client that I would like to integrate with some kind of web application at a later stage?

From the previously reviewed resources, a wide selection of programs is offered: SoapUI, WSDL2Java, Apache Axis, Maven Plugin, JAX-WS, Apache CXF.

I used http://www.soapclient.com/soaptest.html in one of the SO answers mentioned above and I can get the perfect html / xml file on the browser.

Now I'm confused, on which software should I use? The information in the links is a bit in bits and pieces, which I can not compare with each other, since I do not know anything in SOA.

Can someone tell me the high-level steps in writing a standalone Java client that accepts a WSDL URL and SOAP request and gives me its output?

Please let me know if I have missed any information.

+7
java soap wsdl web-services
source share
1 answer

This question depends on the following:

  • The JDK version of your Java compiler.
  • Your version of WSDL (1.0, 1.2, and 2.0 there).

Basically, if you use Java annotations to create web services, then you will need Java 5 related web service libraries (which support annotations).

Some articles about using Java Web Services with annotations (JAX-WS):

I will start by creating a web service client with Java that does not support annotations. The well-known client that generates WSDL for Java is Apache Axis (the latest version 1.4 was released on April 22, 2006). This basically takes a WSDL definition and returns it to the client. It supports the old version of WSDL (1.0) and crashes if you use newer versions of WSDL (1.2 and 2.0).

What this basically does is it takes your WSDL and generates a Java proxy that communicates with your web service. This can enable RPC as well as XML communication.

In Java, which supports annotations, there are two ways to do this:

  • Using the native wsimport Java command (the executable is located in the JDK_HOME/bin/ ).
  • Using third-party libraries such as Apache Axis 2 (which effectively replaces the Apache axis and supports WSDL version 2.0) or Apache CXF (which supports WSDL up to 1.2).

To use wsimport, you basically need to go to a shell command (or write a script) and effectively do some of this effect:

 wsimport -d [outputdir] wsdl_file 

and your Java proxy will be found in the [outputdir] folder.

wsimport is in JDK 1.6 (I don't know if it exists in earlier versions). More here and here .

For the Apache, Apache Axis 2, or Apache CXF axis, there is a WSDL2Java class file that generates source code.

Here is a guide to using WSDL2Java in Apache CXF and in Apache Axis 2 .

I hope this helps you in some way since I spent 30 minutes on it. :-)

+10
source share

All Articles