You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by "Janardhanan, Suresh B" <Su...@duke-energy.com> on 2012/01/19 20:20:59 UTC

CDATA XML String

Andreas,

Thanks for your response. You pointed out that the <![CDATA[ section is actually a character section. But since the soap envelope is getting sent with invalid XML characters the Target .Net web service is sending a code back, which interprets to invalid XML parameters format.

2012-01-18 13:35:20,422 [main] DEBUG httpclient.wire.content  - >> "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:RetrieveByParameter xmlns:ns1="http://wsdl.echelon.com/Panoramix/"><sKey>e1839da0c11c4058928b650f97c06853</sKey><sIDTypeID>f76e5d708edd464593bb031f646990b6</sIDTypeID><sID>100063728</sID><sXmlParameters>&lt;![CDATA[&lt;PARAMETERS>&lt;RETURN>&lt;GENERALINFORMATION>&lt;INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c&lt;/INFORMATIONRETURNTYPEID>&lt;/GENERALINFORMATION>&lt;/RETURN>&lt;/PARAMETERS>]]&gt;</sXmlParameters></ns1:RetrieveByParameter></soapenv:Body></soapenv:Envelope>"

Do you know if there is a way to send the XML string as is?

<![CDATA[<PARAMETERS><RETURN><GENERALINFORMATION><INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c</INFORMATIONRETURNTYPEID></GENERALINFORMATION></RETURN></PARAMETERS>]]>

I also tried changing the WSDL type and that resulted in an Exception - CDATA not allowed in prolog/epilog.

WSDL - changed sXmlParameters type=s:string to xmlStingType as shown below.
      <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  targetNamespace="http://wsdl.echelon.com/Panoramix/">
                  <xsd:complexType name="xmlStringType">
                        <xsd:sequence>
                              <xsd:any xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
                        </xsd:sequence>
                  </xsd:complexType>
            </xsd:schema>
      </wsdl:types>
<wsdl:part name="sXmlParameters" type="tns:xmlStringType" />

Code Snippet:
XmlStringType xmlStrType = new XmlStringType();
      OMElement element = AXIOMUtil.stringToOM(xmlParameters);
      xmlStrType.setExtraElement(element);

Stack Trace:
Caused by:
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'C' (code 67) (CDATA not allowed in prolog/epilog)
at [row,col {unknown-source}]: [1,3]
  Stack Trace:
        org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:297)
        org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:111)
        org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:571)
        org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:567)
        org.apache.axiom.om.util.AXIOMUtil.stringToOM(AXIOMUtil.java:54)
        org.apache.axiom.om.util.AXIOMUtil.stringToOM(AXIOMUtil.java:39)

Thanks much for your help,
Suresh


Re: CDATA XML String

Posted by Andreas Veithen <an...@gmail.com>.
These are lots of questions, and they are completely different from
the question in your original post. That is an indication that you are
focusing too much on the issues you encounter with what you think
might be a solution for your problem, but that you haven't reached a
good understanding of what the actual problem is. If you want to
increase the probability to get a solution for the problem, then you
should start from the beginning, namely with a clear explanation of
what you are trying to achieve and where the problem is.

Andreas

On Thu, Jan 19, 2012 at 20:20, Janardhanan, Suresh B
<Su...@duke-energy.com> wrote:
> Andreas,
>
>
>
> Thanks for your response. You pointed out that the <![CDATA[ section is
> actually a character section. But since the soap envelope is getting sent
> with invalid XML characters the Target .Net web service is sending a code
> back, which interprets to invalid XML parameters format.
>
>
>
> 2012-01-18 13:35:20,422 [main] DEBUG httpclient.wire.content  - >> "<?xml
> version='1.0' encoding='UTF-8'?><soapenv:Envelope
> xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body><ns1:RetrieveByParameter
> xmlns:ns1="http://wsdl.echelon.com/Panoramix/"><sKey>e1839da0c11c4058928b650f97c06853</sKey><sIDTypeID>f76e5d708edd464593bb031f646990b6</sIDTypeID><sID>100063728</sID><sXmlParameters>&lt;![CDATA[&lt;PARAMETERS>&lt;RETURN>&lt;GENERALINFORMATION>&lt;INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c&lt;/INFORMATIONRETURNTYPEID>&lt;/GENERALINFORMATION>&lt;/RETURN>&lt;/PARAMETERS>]]&gt;</sXmlParameters></ns1:RetrieveByParameter></soapenv:Body></soapenv:Envelope>"
>
>
>
> Do you know if there is a way to send the XML string as is?
>
>
>
> <![CDATA[<PARAMETERS><RETURN><GENERALINFORMATION><INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c</INFORMATIONRETURNTYPEID></GENERALINFORMATION></RETURN></PARAMETERS>]]>
>
>
>
> I also tried changing the WSDL type and that resulted in an Exception -
> CDATA not allowed in prolog/epilog.
>
>
>
> WSDL – changed sXmlParameters type=s:string to xmlStingType as shown below.
>
>       <wsdl:types>
>
>             <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
>                   targetNamespace="http://wsdl.echelon.com/Panoramix/">
>
>                   <xsd:complexType name="xmlStringType">
>
>                         <xsd:sequence>
>
>                               <xsd:any
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
>
>                         </xsd:sequence>
>
>                   </xsd:complexType>
>
>             </xsd:schema>
>
>       </wsdl:types>
>
> <wsdl:part name="sXmlParameters" type="tns:xmlStringType" />
>
>
>
> Code Snippet:
>
> XmlStringType xmlStrType = new XmlStringType();
>
>       OMElement element = AXIOMUtil.stringToOM(xmlParameters);
>
>       xmlStrType.setExtraElement(element);
>
>
>
> Stack Trace:
>
> Caused by:
>
> org.apache.axiom.om.OMException:
> com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'C' (code
> 67) (CDATA not allowed in prolog/epilog)
>
> at [row,col {unknown-source}]: [1,3]
>
>   Stack Trace:
>
>
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:297)
>
>
> org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:111)
>
>
> org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:571)
>
>
> org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:567)
>
>         org.apache.axiom.om.util.AXIOMUtil.stringToOM(AXIOMUtil.java:54)
>
>         org.apache.axiom.om.util.AXIOMUtil.stringToOM(AXIOMUtil.java:39)
>
>
>
> Thanks much for your help,
>
> Suresh
>
>