tags:

views:

39

answers:

2

Dear all,

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

+2  A: 

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?

Client stubs w/ XFire

Axis2's wsdl2java

IBM's wsdl2java

Segphault
Hi Segphault, thanks for replying. I tried Axis's wsdl2java for testing a webservice on another project. The stubs generated were quite messy (cannot find a better word, sorry), and I have to pass a request as a String to our platform, so I don't think stubs gonna help? Maybe I used wsdl2java the wrong way?
sarahTheButterFly
@Segphault, reply on your EDIT. Yes, that could be a way to do it. Will have a look.
sarahTheButterFly
Yeah, the generated code is going to be a mess by default -- there are some options you can pass to tighten it up a bit, but I don't remember what exactly (I think it has to do with choice of databinding). Honestly, I have trouble recommending anything from the Axis projects in good conscience since they are such a pile of crap. You may also want to take a look at generating the stub with XFire (added link to original post).
Segphault
Cool. Thanks for the links.
sarahTheButterFly
+1  A: 

You can use SAAJ API for this purpose.

For more details visit these links:

http://download.oracle.com/docs/cd/E17477_01/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

YoK