You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Elam Daly <el...@comcast.net> on 2005/04/28 21:49:25 UTC

Document/Literal Encoding and .NET interop

Howdy all,

I am new to both web-services and Axis.  I have been assigned the task 
of accessing a .net web service which takes one parameter, a string.  
The String has to be data ie: <strData 
type="xsd:string"><data1>data1</data1><data2>data2</data2></strData>.  
But when I send this out over the wire using Axis, all the xml is 
encoded, so < become &lt; and > becomes &gt;. 

 From what I can gather, this has to do with .net web services using 
Document/Literal encoding by default, where as Axis does not.  If this 
is the case, how can I specify Axis to use Document/literal encoding? 

Cheers,
Elam  Daly

Re: Document/Literal Encoding and .NET interop

Posted by Anne Thomas Manes <at...@gmail.com>.
If it is a .NET service, then it will have a WSDL file. If you know
the URL of the service endpoint, append it with "?wsdl", and you
should be able to retrieve the WSDL in a browser. (e.g.,
http://tempuri.org/VRSDataWS/ServerLink?wsdl). If you can't retrieve
it that way, ask the developer to send it to you. (I'm really
surprised that he didn't send it to you in the first place.)

Based on the example you provided, it does appear that the service
expects the following input message:

<xsd:element name="initTransfer">
   <xsd:complexType>
      <xsd:sequence>
         <xsd:element name="strData" type="xsd:string"/>
      </xsd:sequence>
   </xsd:complexType>
</xsd:element>

If you intend to send XML in the string, then it is appropriate for
Axis to escape the XML. .NET will automatically "unescape" it when it
receives it.

Anne

On 4/28/05, Elam Daly <el...@comcast.net> wrote:
> Anne Thomas Manes wrote:
> 
> >Your .NET web service provides a WSDL description of the service
> >interface. Run wsdl2java on this WSDL document, and Axis will generate
> >a Java client proxy for the service. Then you can just invoke
> >operations on this proxy. Axis will automatically generate
> >document/literal if that's what the WSDL says.
> >
> >And btw -- there's no way to send XML data such as
> >"<data1>data1</data1><data2>data2</data2>" as a string within another
> >element without escaping the XML.
> >
> >I expect that the actual input parameter is not in fact a string, it
> >is something like this:
> >
> ><element name="strData">
> >  <complexType>
> >    <sequence>
> >       <element name="data1" type="xsd:string"/>
> >       <element name="data2" type="xsd:string"/>
> >    </sequence>
> >  </complexType>
> ></element>
> >
> >Anne
> >
> >
> Hi Anne,
> 
> I'm pretty sure the web service is expecting one string.  This is the
> description of the .net web service:
> 
>       SOAP
> 
> The following is a sample SOAP request and response. The placeholders
> shown need to be replaced with actual values.
> 
> POST /ServerLink.asmx HTTP/1.1
> Host: [deleted]
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
> SOAPAction: "http://tempuri.org/VRSDataWS/ServerLink/InitTransfer"
> 
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>   <soap:Body>
>     <InitTransfer xmlns="http://tempuri.org/VRSDataWS/ServerLink">
>       <strData>string</strData>
>     </InitTransfer>
>   </soap:Body>
> </soap:Envelope>
> 
> HTTP/1.1 200 OK
> Content-Type: text/xml; charset=utf-8
> Content-Length: length
> 
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>   <soap:Body>
>     <InitTransferResponse xmlns="http://tempuri.org/VRSDataWS/ServerLink">
>       <InitTransferResult>string</InitTransferResult>
>     </InitTransferResponse>
>   </soap:Body>
> </soap:Envelope>
> 
> Regardless, is the wsdl file something that is implicit in the service(
> can I extract it with Axis? ) or do I need to explicity ask the
> developer for the file?
> 
> Thanks for your help,
> Elam Daly
> 
>

Re: Document/Literal Encoding and .NET interop

Posted by Elam Daly <el...@comcast.net>.
Anne Thomas Manes wrote:

>Your .NET web service provides a WSDL description of the service
>interface. Run wsdl2java on this WSDL document, and Axis will generate
>a Java client proxy for the service. Then you can just invoke
>operations on this proxy. Axis will automatically generate
>document/literal if that's what the WSDL says.
>
>And btw -- there's no way to send XML data such as
>"<data1>data1</data1><data2>data2</data2>" as a string within another
>element without escaping the XML.
>
>I expect that the actual input parameter is not in fact a string, it
>is something like this:
>
><element name="strData">
>  <complexType>
>    <sequence>
>       <element name="data1" type="xsd:string"/>
>       <element name="data2" type="xsd:string"/>
>    </sequence>
>  </complexType>
></element>
>
>Anne
>  
>
Hi Anne,

I'm pretty sure the web service is expecting one string.  This is the
description of the .net web service:


      SOAP

The following is a sample SOAP request and response. The placeholders
shown need to be replaced with actual values.

POST /ServerLink.asmx HTTP/1.1
Host: [deleted]
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/VRSDataWS/ServerLink/InitTransfer"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <InitTransfer xmlns="http://tempuri.org/VRSDataWS/ServerLink">
      <strData>string</strData>
    </InitTransfer>
  </soap:Body>
</soap:Envelope>

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <InitTransferResponse xmlns="http://tempuri.org/VRSDataWS/ServerLink">
      <InitTransferResult>string</InitTransferResult>
    </InitTransferResponse>
  </soap:Body>
</soap:Envelope>


Regardless, is the wsdl file something that is implicit in the service( 
can I extract it with Axis? ) or do I need to explicity ask the 
developer for the file?

Thanks for your help,
Elam Daly



Re: Document/Literal Encoding and .NET interop

Posted by Anne Thomas Manes <at...@gmail.com>.
Your .NET web service provides a WSDL description of the service
interface. Run wsdl2java on this WSDL document, and Axis will generate
a Java client proxy for the service. Then you can just invoke
operations on this proxy. Axis will automatically generate
document/literal if that's what the WSDL says.

And btw -- there's no way to send XML data such as
"<data1>data1</data1><data2>data2</data2>" as a string within another
element without escaping the XML.

I expect that the actual input parameter is not in fact a string, it
is something like this:

<element name="strData">
  <complexType>
    <sequence>
       <element name="data1" type="xsd:string"/>
       <element name="data2" type="xsd:string"/>
    </sequence>
  </complexType>
</element>

Anne

On 4/28/05, Elam Daly <el...@comcast.net> wrote:
> Howdy all,
> 
> I am new to both web-services and Axis.  I have been assigned the task
> of accessing a .net web service which takes one parameter, a string.
> The String has to be data ie: <strData
> type="xsd:string"><data1>data1</data1><data2>data2</data2></strData>.
> But when I send this out over the wire using Axis, all the xml is
> encoded, so < become &lt; and > becomes &gt;.
> 
>  From what I can gather, this has to do with .net web services using
> Document/Literal encoding by default, where as Axis does not.  If this
> is the case, how can I specify Axis to use Document/literal encoding?
> 
> Cheers,
> Elam  Daly
>