thanks - don't know whether you have heard of it, but we are uisng a
product called laszlo and even though the xml i return is perfect when i
write a java client to my web service when laszlo is used it escapes the
angle brackets - we have now found out xml isn't supported!
so now i have to re-write my ws
i have this code which returns the xml
StringWriter writer = new StringWriter();
// create a resultsetbuilder to transform resultset to XML
try
{
RecordsetToXML rsXML = new RecordsetToXML(rs, "ROOT", "RECORD");
// create the XML from recordset
Document jDOMDoc = rsXML.build();
rs = null;
XMLOutputter outputter = new XMLOutputter();
outputter.output(jDOMDoc, writer);
result = writer.toString();
//System.out.print("XML " + writer);
writer.close();
}
.......
return result;
So do i do this - [CDATA[writer.toString()]]
when i'm testing i do String ret - (String) call.invoke(new
Object[]{params}); as normal
thanks for your help
From: Guy Rixon <[EMAIL PROTECTED]>
Reply-To: axis-user@ws.apache.org
To: axis-user@ws.apache.org
Subject: Re: xml with strange characters
Date: Wed, 31 Aug 2005 09:17:46 +0100 (BST)
CDATA like this: instead of
String s = "<someXmlStructure>...</someXmlStructure>";
put
String s = "<![CDATA[<someXmlStructure>...</someXmlStructure>]]>";
in the string that you return from your service implementation. This makes
the
return message something like
<soap:envelope>
<soap:body>
<xsd:string>
<![CDATA[<someXmlStructure>...</someXmlStructure>]]>
</xsd:string>
</soap:body>
</soap:envelope>
See
http://www.w3schools.com/xml/xml_cdata.asp
for more details and examples.
However, doing it that way is against the spirit of SOAP. You should really
have your someXmlStructure directly in the body of the message:
<soap:envelope>
<soap:body>
<someXmlStructure>...</someXmlStructure>
</soap:body>
</soap:envelope>
If you mapped someXmlStructure to SomeJavaClass using WSDL2Java, then you
could return an instance of SomeJavaClass from your service implementation
and
Axis would serialize it into the required XML. If you want to generate your
someXmlStructure as a DOM, then you might be able to get that serialized;
check out the SAAJ spec. (Anybody have a succint example of returning a DOM
from a service implementation?) I don't think Axis has a way to accept
serialized XML from a service implementation; i.e. you can't write out
text-with-angle-brackets and have Axis include it literally in the return
message, other than the XML-in-a-string trick that you've already found.
Cheers,
Guy
On Wed, 31 Aug 2005, Plorks mail wrote:
>
> hi
>
> i'm returning the xml as a result of call.invoke. when i write a test
> client using java the xml is well frmed, however we are also usg an
> application called laszlo, but when you get the same xml using laszlo
that's
> whe it comes back with the &alt for the angle brackets
>
> would it be possible to lead me to an example of cdata and sending the
xml
> as the body of the message (i think this is what i'm doing but just want
to
> make sure)
>
> thanks for your help
>
>
> >From: Guy Rixon <[EMAIL PROTECTED]>
> >Reply-To: axis-user@ws.apache.org
> >To: axis-user@ws.apache.org
> >Subject: Re: xml with strange characters
> >Date: Tue, 30 Aug 2005 17:24:35 +0100 (BST)
> >
> >If I understand you correctly, you're putting data marked up as XML in
a
> >string and then sending that string as an XML element in a SOAP
message. In
> >this usage, Axis has to turn the angle brackets into entity references
in
> >order to make the XML well-formed; you're not allowed to have literal
angle
> >brackets in the value of an XML element.
> >
> >If you desparately need to send your XML structure as the value of
> >some XML element, then you can wrap it in a CDATA section so that Axis
need
> >not mess
> >with the angle brackets. However, why not just send the XML as the body
of
> >the
> >message (normal document/literal style)?
> >
> >On Tue, 30 Aug 2005, Plorks mail wrote:
> > >
> > > it's not - when the client receives the xml it has &alt instead of <
or
> > >
> > >
> > > Also when i test my service get the same characters in the soap
message
> > >
> > > Thanks
> > >
> > >
> > >
> > > >From: WAJSBERG Julien RD-BIZZ <[EMAIL PROTECTED]>
> > > >Reply-To: axis-user@ws.apache.org
> > > >To: axis-user@ws.apache.org
> > > >Subject: Re: xml with strange characters
> > > >Date: Tue, 30 Aug 2005 14:30:59 +0200
> > > >
> > > >Plorks mail a écrit :
> > > >
> > > > >
> > > > > hi all
> > > > >
> > > > > i'm retruning a xml string when a method is called.
> > > > >
> > > > > When i look at the soap returned xml is formatted with <
> >charactes
> > > > > instead of < or >
> > > > >
> > > > > e.g.
> > > > >
> > > > > <ROOT>
> > > > > ............
> > > > > </ROOT>
> > > > >
> > > > > can anyone help me to solve this
> > > > >
> > > >Why is it a problem ?
> > > >Axis should deserialize this message correctly on the client
side...
> > > >
> > >
> > > _________________________________________________________________
> > > Want to block unwanted pop-ups? Download the free MSN Toolbar now!
> > > http://toolbar.msn.co.uk/
> > >
> >
> >Guy Rixon [EMAIL PROTECTED]
> >Institute of Astronomy Tel: +44-1223-337542
> >Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
>
> _________________________________________________________________
> Want to block unwanted pop-ups? Download the free MSN Toolbar now!
> http://toolbar.msn.co.uk/
>
Guy Rixon [EMAIL PROTECTED]
Institute of Astronomy Tel: +44-1223-337542
Madingley Road, Cambridge, UK, CB3 0HA Fax: +44-1223-337523
_________________________________________________________________
Winks & nudges are here - download MSN Messenger 7.0 today!
http://messenger.msn.co.uk