ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ajit Bhingarkar <abhin...@tibco.com>
Subject RE: Axis client CDATA XML in a string request
Date Fri, 20 Jan 2012 06:16:51 GMT
In my case xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, false); worked. XML aware
editors show CDATA wrapped string correctly even though raw data may appear so.

Regards,
Ajit

________________________________
From: Suresh Janardhanan [mailto:suresh.janardhanan@gmail.com]
Sent: 20 January 2012 06:02
To: users@ws.apache.org; dev@ws.apache.org
Subject: Axis client CDATA XML in a string request

Andreas,

I'll try to start from the beginning and explain what I am trying to achieve as you suggested.
I generated a web service client for a .NET Target web service using Apache Axis 2.1.6.1.
Here is a snippet of the .Net WSDL.
            <wsdl:message name="RetrieveByParameterSoapIn">
                        <wsdl:part name="sKey" type="s:string" />
                        <wsdl:part name="sIDTypeID" type="s:string" />
                        <wsdl:part name="sID" type="s:string" />
                        <wsdl:part name="sXmlParameters" type="s:string" />
            </wsdl:message>
The Target expects an XML string to be set in "sXmlParameters", something like this -
<![CDATA[<PARAMETERS><RETURN><GENERALINFORMATION><INFORMATIONRETURNTYPEID>3294f665bc644359bfd15824d2efe29c</INFORMATIONRETURNTYPEID></GENERALINFORMATION></RETURN></PARAMETERS>]]

Since it is a "string type", Axis client is converting the characters - < and >
So, the request looks like this -
[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>"

My objective is to send the XML string inside "sXmlParameters" as is without the <, >
getting converted.

So I tried these steps.
1. I thought by adding XMLInputFactory.properties - javax.xml.stream.isCoalescing=false, it
would the issue. But you pointed out that since it is character data this won't work.
2. I tried changing the "sXmlParameters" type in the wsdl, but that resulted in com.ctc.wstx.exc.WstxUnexpectedCharException.
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