ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Janardhanan, Suresh B" <Suresh.Janardha...@duke-energy.com>
Subject RE: Axis client - adding CDATA XML string to request
Date Tue, 24 Jan 2012 15:07:44 GMT
Andreas,

Thank you very much for your suggestion. Yes, if I pass just the XML without the CDATA Begin
and End Tag the .Net web service comes back with a valid response.
<PARAMETERS><RETURN><GENERALINFORMATION><INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c</INFORMATIONRETURNTYPEID></GENERALINFORMATION></RETURN></PARAMETERS>

I am not sure why that's the case. The reason the .Net web service has CDATA Begin and End
tag wrapped around the XML is to treat it as a string value, even if It is not a well-formed
XML. I am working on testing this solution against all the WSDL Operations and check if works
correctly.

Thanks again for your direction.

Suresh

Hi,

I generated my web services client using Apache Axis v2.1.6.1. The .Net target web service
has the following in its WSDL -

<wsdl:part name="sXmlParameters" type="s:string" />

I am expected to set the following string for sXmlParameters.
xmlParameters=<![CDATA[<PARAMETERS><RETURN><GENERALINFORMATION><INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c</INFORMATIONRETURNTYPEID></GENERALINFORMATION></RETURN></PARAMETERS>

When it is sent through Apache Axis client, the XML characters <, > are getting converted
-
[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>"

Is there any way to send the XML string as is?

I also tried changing the WSDL type, which resulted in an Exception.

This is what I changed in the 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)

Any help is much appreciated.

Thanks,
Suresh


Mime
View raw message