Note that there are some explanatory texts on larger screens.

plurals
  1. POSAP Netweaver SOAP Service returning null response to WCF client
    text
    copied!<p>I've added a SAP Netweaver service reference to my project using a local WSDL. The server returns a null response, but using Fiddler I can see the correct response is being sent. I assume this means the response isn't being deserialized correctly. This is how the root response element is defined in the WSDL:</p> <pre><code>&lt;xsd:element name="adrl"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element ref="adr" minOccurs="0" maxOccurs="unbounded"/&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; </code></pre> <p>The child element (some fields elided):</p> <pre><code>&lt;xsd:element name="adr"&gt; &lt;xsd:complexType&gt; &lt;xsd:sequence&gt; &lt;xsd:element ref="id"/&gt; &lt;/xsd:sequence&gt; &lt;xsd:attribute name="op" use="required"&gt; &lt;xsd:simpleType&gt; &lt;xsd:restriction base="xsd:NMTOKEN"&gt; &lt;xsd:enumeration value="update"/&gt; &lt;xsd:enumeration value="delete"/&gt; &lt;/xsd:restriction&gt; &lt;/xsd:simpleType&gt; &lt;/xsd:attribute&gt; &lt;/xsd:complexType&gt; &lt;/xsd:element&gt; </code></pre> <p>Response:</p> <pre><code>&lt;wsdl:output message="p1:p2.adrl"/&gt; </code></pre> <p>Namespaces:</p> <pre><code>xmlns:p1="urn:mycompany:outbound" xmlns:p2="http://tempuri.org/mycompany" </code></pre> <p>SOAP response from service:</p> <pre><code>&lt;SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'&gt; &lt;SOAP:Header/&gt; &lt;SOAP:Body&gt; &lt;adrl&gt; &lt;adr op='update'&gt; &lt;id&gt;9AF1FBA0-81A4-4427-A011-0DCE3BD1F609&lt;/id&gt; &lt;/adr&gt; &lt;/adrl&gt; &lt;/SOAP:Body&gt; &lt;/SOAP:Envelope&gt; </code></pre> <p>WCF class definitions (from Reference.cs):</p> <pre><code>// Some namespaces elided [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.17929")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://tempuri.org/mycompany")] public partial class adr : object, System.ComponentModel.INotifyPropertyChanged { private string idField; // adrOP has a suitable enumeration defined elsewhere in the file private adrOP opField; /// &lt;remarks/&gt; [System.Xml.Serialization.XmlElementAttribute(Order=0)] public string id { get { return this.idField; } set { this.idField = value; this.RaisePropertyChanged("id"); } } /// &lt;remarks/&gt; [System.Xml.Serialization.XmlAttributeAttribute()] public adrOP op { get { return this.opField; } set { this.opField = value; this.RaisePropertyChanged("op"); } } public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged; if ((propertyChanged != null)) { propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); } } } [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] public partial class GetAdrResponse { [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://tempuri.org/mycompany", Order=0)] [System.Xml.Serialization.XmlArrayItemAttribute("adr", IsNullable=false)] public adr[] adrl; public GetAdrResponse() { } public GetAdrResponse(adr[] adrl) { this.adrl = adrl; } } </code></pre> <p>When I try manually deserializing the response I captured in Fiddler (with adrl as the root element) I get the and Xml error with the inner exception message "" was not expected. If I <a href="https://stackoverflow.com/questions/1556874/user-xmlns-was-not-expected-deserializing-twitter-xml">add a root element</a> to the serializer the error disappears, but only the "op" attribute is properly deserialized. The rest of the fields are null.</p> <p>What could be the problem? I don't really have access to the Service but if there's something that has to change there I can forward a request. Otherwise I'm contemplating adding a MessageInspector and modifying the response, but I'm not really sure in which way it should be modified.</p> <p>EDIT: I created the object in C# and deserialized it and this was the result:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;ArrayOfAdr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;adr op="update"&gt; &lt;id&gt;9AF1FBA0-81A4-4427-A011-0DCE3BD1F609&lt;/id&gt; &lt;/adr&gt; &lt;/ArrayOfAdr&gt; </code></pre> <p>It seems like the root element is not properly defined in terms of serialization.</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