Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java-WS: is it possible to send a request argument as XML?

 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi -

I'm writing a Java webservice client that will be running on WebSphere. I created a new "Web Service Client" project in RAD Developer, gave it my WSDL, specified "Top down Java Bean", and it autogenerated a bunch of files.

One of the operations is "GetAddressData". RAD Developer auto-generated "GetAddressData.java" and "GetAddressDataResonse.java", both annotated with "XmlRootElement".

One of the arguments in "GetAddressData" is "RequestData", a simple object consisting of four strings: worfklow, module, username, and id. RAD Developer generated a "RequestData.java" for me too.

Q: Is there any way that I can substitute raw XML for the JAXB "RequestData" object, instead of packing and unpacking the record a field at a time?

I tried something like this:



But I keep getting:



Any help would be deeply appreciated! Thank you in advance.

 
Ivan Jozsef Balazs
Rancher
Posts: 981
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A naive question: did you deliberately omit the XML header?

 
Shankar sanjay
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried with @XMLRootElement annotation in RequestData.java class?
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you have "requestOptions" in lower case, did you override it in JAXB bean?
 
g tsuji
Ranch Hand
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul Santa Maria
Q: Is there any way that I can substitute raw XML for the JAXB "RequestData" object, instead of packing and unpacking the record a field at a time?

A: A priori, you can. It is done not dissimilar to what is done with handcraft pojo with annotations even though in your case classes are created by code generation in the possibly top-down approach.

But before getting into details, you've to clarify RequestData here in the question and RequestOptions appeared below: do you mean them being the same thing due to some kind of typo in posting the question? See, your xml has requestOptions root... If you mean all be RequestData, everywhere Options should be read as Data (unless some unknown customization that cannot be guessed without showing.)

Suppose the annotations appeared in the RequestData.java are done favorably, you could get back the RequestData instance via JAXBElement<T> class. The big plot may look like this.

And then you can verify its property, say ModuleName, like this.
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The topic starter cross-posted the question which seems to be answered already. (See the link).
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
g tsuji wrote:


Could you please post RequestData bean?
 
g tsuji
Ranch Hand
Posts: 669
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please post RequestData bean?

If you have a question of your own, you can post in a separate thread of your own specifying your concerns and efforts made.

RequestData bean and the question is not mine. In principle I would leave the op to come forward to help if you need one. Since they have, I can help you with a very basic but functional which illustrates the point.
 
surlac surlacovich
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the code.
g tsuji wrote:
Could you please post RequestData bean?

If you have a question of your own, you can post in a separate thread of your own specifying your concerns and efforts made.

The code is relevant for this thread, thus it has been asked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic