This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Web Services and the fly likes javax.xml.soap.SOAPElement  addTextNode(String) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "javax.xml.soap.SOAPElement  addTextNode(String)" Watch "javax.xml.soap.SOAPElement  addTextNode(String)" New topic
Author

javax.xml.soap.SOAPElement addTextNode(String)

ahmad namini
Ranch Hand

Joined: Aug 29, 2002
Posts: 52
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.


-Ahmad<br />Sun Certified Java Developer (SCJD)<br />Sun Certified Java Programmer (SCJP)<p>"You got to be careful if you don't know where you're going, because you might not get there." -Yogi Berra
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
If you want to add the string "as XML" instead of "as a string", you need to use addChildElement(...).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
ahmad namini
Ranch Hand

Joined: Aug 29, 2002
Posts: 52
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: javax.xml.soap.SOAPElement addTextNode(String)