Search code examples
javaxmlweb-servicessoapapache-axis

How to get Soap output data with a java client created with wsdl2java


I'm creating a simple java client to call a webservice.

To create the stub classes I used wsdl2java. Many classes have been created, I execute the webservice correctly passing the input.

The problem is that I don't know how to get the webservice result.

I have the following classes for my operation:

MyOperationResponse (correctly valorized by the webservice)

MyOperationResult_type0 (obtained by MyOperationResponse.getMyOperationResult, the abstract class is org.apache.axis2.databinding.ADBBean) 

Now in MyOperationResult_type0 I don't see any method to get output values!

I see a getOMElement method in which I have to pass some parameters QName and OMFactory... Is it the way to go? If it is, why it is so complicate?

Is it not possible to work directly with the dom xml of the response? Thank you!


Solution

  • You should try to use wsimport instead.

    wsimport comes with your JDK and it generates JAXWS clients.

    Here the command

    "path_to_your_jdk\bin\wsimport.bat" -d "D:\WS" -p com.your.package.name.wsclient.nameoftheservice -keep -verbose yourwsdl.wsdl
    

    The client it generates are easier to deal with. You just need to instanciate the Service, get the proxy and call the service with the proxy.