开发者

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 servi开发者_运维技巧ce, 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


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


You can use SAAJ API for this purpose.

For more details visit these links:

  • http://docs.oracle.com/javaee/5/tutorial/doc/bnbhg.html
  • https://saaj.dev.java.net/nonav/spec-1.3/api/
  • http://lia.deis.unibo.it/Courses/TecnologieWeb0708/materiale/laboratorio/guide/j2ee14tutorial7/SAAJ3.html


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜