If you're doing message-style SOAP, you can return the DOM Element and 
it'll go through fine.  When you return a string with special characters in 
it, those need to be replaced by entities so the parser on the other 
translates them correctly back to the proper character rather than 
interpreting them as the start of an XML element or whatever.  I just tried 
returning a string with XML in it from a .jws file, and Axis XML-encodes 
the string for you.  Guess it would have to, since there's no telling what 
could be in a string.  If you ever want to do it manually for some reason, 
there's a static function to do this in Axis's XMLUtils class:

xmlEncodeString

public static java.lang.String xmlEncodeString(java.lang.String orig)

Encode a string appropriately for XML. Lifted from ApacheSOAP 2.2 
(org.apache.soap.Utils)
Parameters:
orig - the String to encode
Returns:
a String in which XML special chars are repalced by entities

Andrew

At 06:26 PM 7/24/2002 -0500, you wrote:
>On Wednesday 24 July 2002 02:51 pm, Andrew Vardeman wrote:
>I have a web service(running on Axis-- I am not using .NET) that reads in an
>XML doc and returns it as an Element.  However, when the SOAP response is
>generated all of the >'s, &'s, etc are not escaped.
>
>You mention xml encoding--what is the proper way to do this?  I want to 
>encode
>a String (which is XML to begin with) to preserve the  XML structure.
>
>Thanks in advance
>
>Eric
>
>
> > I'm passing XML documents back and forth between Axis and .NET using
> > doc/lit (message style).  I figured it was the most natural way to go since
> > the SOAP envelope is XML.  Axis makes doc/lit really easy; .NET is so bent
> > on serializing and deserializing everything for you that it took some work
> > figuring out how to give it an XML document and say "just stick this in the
> > SOAP Body."  RPC works fine too (just XML-encode the document to escape
> > the >'s, &'s, etc. and send it as a string), and it might save you some
> > hassle, but the escaping will make your messages a little longer if size is
> > important.  I guess it depends on what you plan to do with the document
> > when it gets to the other end...
> >
> > Andrew
> >
> > At 02:37 PM 7/24/2002 -0500, you wrote:
> > >i'm trying to figure out the best way to do this. Has anyone implemented a
> > >web service with axis where you pass an entire xml document as the
> > > payload? if so, did you use a rpc style or a message style service?
> > >
> > >thanks!
> > >mark
>
>--
>Eric Roberts
>Web Service Developer for Grid Technologies
>Texas Advanced Computing Center
>[EMAIL PROTECTED]



Reply via email to