Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know why WCF ignores XmlRoot, so I can't answer that part of your question. But I do have a couple ways to solve the problem.</p> <ol> <li><p><strong>start with WSDL first.</strong><br> If you have a particular set of XML namespaces you would like to apply to the messages that get sent and receieved, use WSDL and XML Schema to explicitly specify them.</p> <p>Then, generate the Server-side stub code, or the client-side proxy code, directly from that WSDL via <a href="http://msdn.microsoft.com/en-us/library/aa347733.aspx" rel="nofollow noreferrer">the svcutil.exe tool</a>. </p></li> <li><p><strong><a href="http://blogs.msdn.com/dotnetinterop/archive/2007/07/19/interop-between-asmx-and-wcf-services.aspx" rel="nofollow noreferrer">use a custom ServiceHost</a></strong><br> The other option open to you, described at <a href="http://blogs.msdn.com/dotnetinterop/archive/2007/07/19/interop-between-asmx-and-wcf-services.aspx" rel="nofollow noreferrer">this link</a>, is to use a custom ServiceHost that overrides WCF's decision to disregard the XmlRoot or XmlType attributes on message types. </p></li> </ol> <hr> <p>If you choose to go for the WSDL-First approach, the WSDL should look like this: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;definitions xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:The-Service-namespace" xmlns:tns="urn:The-Service-namespace" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:n0="urn:The-Request-namespace" xmlns:n1="urn:The-Response-namespace" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" elementFormDefault= "unqualified" &gt; &lt;types&gt; &lt;s:schema targetNamespace="urn:The-Request-namespace" &gt; &lt;s:complexType name="Type1"&gt; &lt;s:sequence&gt; &lt;s:element name="x" minOccurs="1" maxOccurs="1" type="s:string"/&gt; &lt;/s:sequence&gt; &lt;/s:complexType&gt; &lt;s:element name="Type1" type="n0:Type1" /&gt; &lt;/s:schema&gt; &lt;s:schema targetNamespace="urn:The-Response-namespace" &gt; &lt;s:complexType name="Type2"&gt; &lt;s:sequence&gt; &lt;s:element name="x" minOccurs="1" maxOccurs="1" nillable="false" type="s:string"/&gt; &lt;s:element name="y" minOccurs="1" maxOccurs="1" nillable="false" type="s:int"/&gt; &lt;s:element name="z" minOccurs="1" maxOccurs="1" nillable="false" type="s:boolean" /&gt; &lt;/s:sequence&gt; &lt;/s:complexType&gt; &lt;s:element name="Type2" type="n1:Type2" /&gt; &lt;/s:schema&gt; &lt;/types&gt; &lt;message name="RequestMessage"&gt; &lt;part name="inPart1" element="n0:Type1" /&gt; &lt;/message&gt; &lt;message name="ResponseMessage"&gt; &lt;part name="outPart1" element="n1:Type2" /&gt; &lt;/message&gt; &lt;portType name="PortTypeName"&gt; &lt;operation name="Method1"&gt; &lt;input message="tns:RequestMessage" /&gt; &lt;output message="tns:ResponseMessage" /&gt; &lt;/operation&gt; &lt;/portType&gt; &lt;binding name="InterfaceName" type="tns:PortTypeName"&gt; &lt;soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" /&gt; &lt;operation name="Method1"&gt; &lt;soap:operation soapAction="" style="document" /&gt; &lt;input&gt; &lt;soap:body use="literal" /&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="literal" /&gt; &lt;/output&gt; &lt;/operation&gt; &lt;/binding&gt; &lt;/definitions&gt; </code></pre> <hr> <p>This WSDL is very simple - it defines a single operation, with a single request message and a single response message. </p> <p>Notice there are three xml namespaces:</p> <ul> <li><strong>urn:The-Service-namespace</strong><br> used for the element that wraps the request and response - the first element inside the &lt;SOAP:body&gt;</li> <li><strong>urn:The-Request-namespace</strong><br> used for the element wrapped inside that request wrapper, which gets deserialized into an instance of Type1. </li> <li><strong>urn:The-Response-namespace</strong><br> used for the element wrapped inside that response wrapper, which gets deserialized into an instance of Type2.</li> </ul> <p>If your web services interface is more complicated, has more operations and consequently more request and response message types, you can add more namespaces, if you like, for all those additional types. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload