• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML within string parameter to RPC Service

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am going to be using Axis to invoke an RPC style web service which takes a single string parameter. This string parameter is going to contain an XML message. What I am wondering is if I need to wrap this String in a CDATA section before I invoke the web service?
From reading the XML specification it says that character data consists of any text that does not contain markup. However my string value will contain markup. I have tested invoking the web service without wrapping my String in a CDATA section and have found that Axis has changed all the markup characters into their respective entity references (i.e. < has become < ). What Im wondering is why Axis is doing this? Im not sure how it creates its SOAP messages but from a brief glance of the code I guess it a DOM (rather than plain String manipulation ). From looking at the DOM API it does not mention anything about the createTextNode method parsing the text content and expanding markup to use entity references?
Any recommendations or pointers as to what should influence whether the text should be wrapped in a CDATA section would help....
Cheers,
John
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's safer to let Axis encode the markup characters. In theory, you never know whether the XML string contains a <![CDATA[foobar]]> itself where the extra occurrence of "]]>" would cause trouble...
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm in the similar situation as John.

I think wrapping the string in CDATA may help become the result xml valid.

E.g. string may contain:
 
reply
    Bookmark Topic Watch Topic
  • New Topic