Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generic Soap Client in Java

Tags:

java

soap

I am new to SOAP Webservices. My requirement is to create a testing tool like SOAP UI wherein The inputs would be the URL of the Concrete WSDL and the operation. My task is to create SOAP Client Dynamically based on the WSDL and the operation. I am using java. Can anyone help me out with the java code?

like image 586
Darshana Avatar asked Feb 02 '11 08:02

Darshana


3 Answers

Have a look at Axis2 an the especially the client generation.

http://axis.apache.org/axis2/java/core/docs/userguide-creatingclients.html

like image 81
flash Avatar answered Oct 01 '22 12:10

flash


You dont really need to generate a SOAP client. You can use something like HTTPClient to post the request SOAP XML. This way whatever WSDL all you need to do is create a xml.

http://www.java-tips.org/other-api-tips/httpclient/how-to-send-an-xml-document-to-a-remote-web-server-using-http-5.html

like image 44
Pushkar Avatar answered Oct 01 '22 14:10

Pushkar


Any reason why you're not using SoapUI to do this? As you point out, it does exactly what you want (and, FWIW, it's a Java app ;-) ).

Anyway, both the Axis and CXF web service frameworks (Apache) have wsdl2j implementations that will generate your client stubs for you: you provide a WSDL URI as an argument on the command line when you invoke a wsdl2j instance (this is the same code used under the covers by SoapUI, when generating a client with the relevant framework), and the class generates your stubs.

You might find this question useful: What methods exist to auto-generate java client stubs from WSDL files?

like image 39
Ben Avatar answered Oct 01 '22 12:10

Ben