Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET WCF serialization issues
    text
    copied!<p>The situation: system A is supposed to expose SOAP 1.2 web service for system B to call. In order for A to know what the message looks like, B sent an XSD to A describing the contents of the message. A generated the stubs using the .NET xsd.exe tool, created the simple webservice around this and the job was done.</p> <p>However; when B calls this webservice, A refuses to serialize the SOAP/XML content to the generated proxy class instances. I realize this must be down to the way the serialization is defined on the webservice side on system A, but have been unable to locate exactly what is going wrong.</p> <p><strong>What the message from B looks like (anonymized) - FAILS:</strong></p> <pre><code>&lt;ns2:Set_Out xmlns:ns2="http://a.a/1.0" xmlns:ns1="http://b.b/1.0" xmlns:ns0="http://c.c"&gt; &lt;Context xmlns=""&gt; &lt;Foo&gt;test&lt;/Foo&gt; &lt;Bar&gt;test&lt;/Bar&gt; ... &lt;/Context&gt; </code></pre> <p><strong>What a test message from a test client (based on the WSDL) looks like - WORKS:</strong></p> <pre><code>&lt;Set_Out xmlns="http://a.a/1.0"&gt; &lt;Context xmlns:b="http://schemas.datacontract.org/2004/07/x.x" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;b:Foo&gt;TEST&lt;/b:Foo&gt; &lt;b:Bar&gt;test&lt;/b:Bar&gt; ... &lt;/Context&gt; </code></pre> <p>When the webservice built by A receives the messages from B, it doesn't serialize the message at all. The objects of the proxy (for instance <code>Context</code>) are <code>null</code>. When it receives the messages from a test client, everything is generated correctly.</p> <p><strong>The serialization attributes on the proxy:</strong></p> <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://a.a/1.0")] [System.Xml.Serialization.XmlRootAttribute(Namespace="http://a.a/1.0", IsNullable=false)] [System.ServiceModel.MessageContract] public partial class Set_Out { [System.Xml.Serialization.XmlElementAttribute(Namespace="http://a.a/1.0", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.ServiceModel.MessageBodyMember(Order=0)] public ContextType Context; ... [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://a.a/1.0")] public partial class ContextType { [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string Foo; </code></pre> <p>Things I find odd:</p> <ol> <li>When generating the WSDL for this service, the WSDL adds its own namespaces to the WSDL definition (<code>xmlns:b</code> in the example above, for instance).</li> <li>The WSDL doesn't respect the <code>unqualified</code> annotations defined in the proxy, and makes everything qualified.</li> </ol> <p>I've tried various combinations of annotations, but nothing seems to help; the messages from B aren't correctly deserialized to the proxies generated by A. Any ideas/pointers/help would be much appreciated!</p>
 

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