This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes SOA and ESB and the fly likes Java-WS: is it possible to send a request argument as XML? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » SOA and ESB
Bookmark "Java-WS: is it possible to send a request argument as XML?" Watch "Java-WS: is it possible to send a request argument as XML?" New topic
Author

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

Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
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.


Paul M. Santa Maria, SCJP
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 866
    
    5
A naive question: did you deliberately omit the XML header?

Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
Have you tried with @XMLRootElement annotation in RequestData.java class?
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

Why do you have "requestOptions" in lower case, did you override it in JAXB bean?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
@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

Joined: Mar 12, 2013
Posts: 296

The topic starter cross-posted the question which seems to be answered already. (See the link).
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

g tsuji wrote:


Could you please post RequestData bean?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
    
    3
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

Joined: Mar 12, 2013
Posts: 296

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java-WS: is it possible to send a request argument as XML?
 
Similar Threads
Using java.lang.Arraylist object in WSAD WebServices
JAX WS not producing correct HTTP request
Treat in memory string as file
Exception thrown while invoke .NET service from Java client
problem converting xml into bean using betwixt