Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.xml.soap.SOAPElement addTextNode(String)

 
ahmad namini
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a String which has xml markup within it. I need to append this String as XML encoded text within a SOAP Body. javax.xml.soap.SOAPElement has the addTextNode(String) method but all the markup is encoded with escape sequences instead.
Does anyone know how to encode this properly?
Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to add the string "as XML" instead of "as a string", you need to use addChildElement(...).
 
ahmad namini
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response Lasse.
I have indeed tried addChildElement(). However, this method assumes that the string is the tag name, and thus adds < and /> at the beginning and end of my string.
I did in fact solve my problem by essentially writing a recursive deep copy method which starts at the root element and appends each child element and its child element and so forth with its attributes, namespaces, and content.
Works great. You would think that a nice method would be provided within the SAAJ or the JAXM libraries. If there is, I couldn't find it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic