• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A naive question: did you deliberately omit the XML header?

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried with @XMLRootElement annotation in RequestData.java class?
 
Ranch Hand
Posts: 296
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you have "requestOptions" in lower case, did you override it in JAXB bean?
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

g tsuji wrote:


Could you please post RequestData bean?
 
g tsuji
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic