axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Plorks mail" <plork...@hotmail.com>
Subject RE: xml with strange characters
Date Wed, 31 Aug 2005 09:05:23 GMT

I use document/literal sytle


looking at the soap using tcpmon it looks like this


<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
  <getListResponse xmlns="">
   <getListReturn>&lt;![CDATA[&lt;?xml version=&quot;1.0&quot; 
encoding=&quot;UTF-8&quot;?&gt;&#xd;
&lt;ROOT&gt;&lt;RECORD&gt;&lt;id&gt;1&lt;/id&gt;&lt;id&gt;1&lt;/id&gt;&lt;contactid&gt;20&lt;/contactid&id&gt;1&lt;/id&gt;&lt;contactid&gt;29&lt;/contactid&gt;&lt;emailcount&gt;2&lt;/emailcount&gt;&lt;emailaddress&gt;jkl@email.com&lt;/emailaddress&gt;&lt;/RECORD&gt;&lt;/ROOT&gt;&#xd;
]]&gt;</getListReturn>
  </getListResponse>
</soapenv:Body>
</soapenv:Envelope>


but when i retutn the result using call.invoke the xml is well formed






>From: "Chris Nappin" <C.Nappin@ABM-UK.COM>
>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:57:17 +0100
>
>You might be able to get away with that if you know your XML never contains 
>"]]".
>
>The "proper" way to pass XML in a web service is to use the 
>"document/literal" style - have a look at the Axis User guide for further 
>details.
>
>
>-----Original Message-----
>From: Plorks mail [mailto:plork123@hotmail.com]
>Sent: 31 August 2005 09:52
>To: axis-user@ws.apache.org
>Subject: Re: xml with strange characters
>
>
>
>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 <gtr@ast.cam.ac.uk>
> >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 <gtr@ast.cam.ac.uk>
> > > >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 <julien.wajsberg@francetelecom.com>
> > > > > >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
&lt;
> > > >charactes
> > > > > > > instead of < or >
> > > > > > >
> > > > > > > e.g.
> > > > > > >
> > > > > > > &lt;ROOT&gt;
> > > > > > > ............
> > > > > > > &lt;/ROOT&gt;
> > > > > > >
> > > > > > > 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 				        gtr@ast.cam.ac.uk
> > > >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 				        gtr@ast.cam.ac.uk
> >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
>
>
>
>
>CONFIDENTIALITY & PRIVILEGE NOTICE
>
>This e-mail is confidential to its intended recipient. It may also be 
>privileged. Neither the confidentiality nor any privilege attaching to this 
>e-mail is waived lost or destroyed by reason that it has been mistakenly 
>transmitted to a person or entity other than its intended recipient. If you 
>are not the intended recipient please notify us immediately by telephone or 
>fax at the numbers provided above or e-mail by Reply To Author and return 
>the printed e-mail to us by post at our expense. We believe, but do not 
>warrant, that this e-mail and any attachments are virus-free, but you 
>should check. We may monitor traffic data of both business and personal 
>e-mails. We are not liable for any opinions expressed by the sender where 
>this is a non-business e-mail. If you do not receive all the message, or if 
>you have difficulty with the transmission, please telephone us immediately.

_________________________________________________________________
Winks & nudges are here - download MSN Messenger 7.0 today! 
http://messenger.msn.co.uk


Mime
View raw message