Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding JAXB object to Soap Header

 
udhaya kumarG
Greenhorn
Posts: 15
Eclipse IDE Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you please tel me how to add the JAXB Object to SOAP Header using JAX-WS???


Thanks in Advance..
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
The usual way to manipulate the headers of a SOAP message using Java is through an object implementing the SOAPHeader interface.
After some calls, you will get an object implementing the SOAPElement interface. This interface extends the DOM interfaces Element and Node, thus you can add a DOM node to a SOAPHeader object.
Then you need to transform the JAXB object into a DOM object, before you can add it to the SOAPHeader object. Take a look at the JavaSE 6 API documentation for javax.xml.bind.Marshaller on how to do this.

An alternate route is to manipulate a string representing the XML message. This is not the solution I would prefer, but it may reduce the amount of code you have to write.

A third alternative is using Groovy, which is good at XML manipulation, or some additional framework. If you have restrictions imposed on you, this may not be a viable option.
Best wishes!
 
udhaya kumarG
Greenhorn
Posts: 15
Eclipse IDE Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ivan Krizsan,

Thanks for your Reply.. I got it. Working fine now!
 
Vikas Chandra
Greenhorn
Posts: 2
Android Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be possible to post the code sample. I guess I am missing something while trying to achieve the same
Vikky Chan
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic