sarahTheButterFly
sarahTheButterFly

Reputation: 1952

Compose Soap Request in Java

I have a wsdl file and a detailed document about all the elements in every request and response from a web-service provider. My job is to compose around 40 requests and parse corresponding responses.

More specifically, our platform submits the requests and gets responses from the service, so for me, as an application developer, I only need to compose soap requests and pass them as String to the platform. I also get response as String from the platform.

I tried StringBuilder, but it looks pretty primitive. It has to be a better way to do it.

Can I put all the requests in an xml document and somehow generate requests from it?

Or even better, is it possible to generate requests from the wsdl file?

Thanks,

Sarah

Upvotes: 4

Views: 1446

Answers (3)

MariuszS
MariuszS

Reputation: 31577

The simplest way is soap-ws library: https://github.com/reficio/soap-ws

   SoapClient client = SoapClient.builder()
        .endpointUrl("http://rpc.middleearth.com")
        .build();

   client.post(envelope);

Upvotes: 0

Justin Garrick
Justin Garrick

Reputation: 14947

Have a look at the wsdl2java utilities (there are several versions, one packaged with Axis2, another from IBM, etc.). These can generate client stubs from your WSDL, and should save you a considerable amount of work.

EDIT: Just realized that this may require some additional work since you say your platform submits the requests. The generated code should be attempting to submit strings to the service if that is what's specified by your WSDL, perhaps you can modify the code to pass the strings to your platform?

JAX-WS's wsimport

Client stubs w/ XFire

Axis2's wsdl2java

IBM's wsdl2java

Upvotes: 2

Related Questions