0

I'm trying to find what's wrong with this WSDL-based service in c#.

The WSDL contains a lot of information but the ones related to the method in question looks like this:

<wsdl:operation name="GetStock">
<wsdl:input message="tns:GetStockRequest"/>
<wsdl:output message="tns:GetStockResponse"/>
</wsdl:operation>

<wsdl:message name="GetStockResponse">
<wsdl:part name="parameters" element="tns:GetStockResponse"/>
</wsdl:message>

<xsd:element name="GetStockResponse">
<xsd:complexType>
<xsd:sequence>
 <xsd:element name="Items" minOccurs="0" maxOccurs="1" type="tns:ArrayOfItems"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:complexType name="ArrayOfItems">
<xsd:sequence>
<xsd:element name="Item" minOccurs="0" maxOccurs="unbounded" nillable="true" type="tns:Item"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ArrayOfItems" type="tns:ArrayOfItems"/>

<xsd:complexType name="Item">
<xsd:sequence>
<xsd:element name="ItemNo" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="StoreID" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="NotInERP" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="DeliveryTimeText" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="DeliveryDays" minOccurs="0" maxOccurs="1" type="xsd:integer"/>
<xsd:element name="InStockQty" minOccurs="0" maxOccurs="1" type="xsd:integer"/>
<xsd:element name="InShowRoom" minOccurs="0" maxOccurs="1" type="xsd:string"/>
<xsd:element name="Points" minOccurs="0" maxOccurs="1" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Item" type="tns:Item"/>

The created Reference.cs for this service looks like this

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="Item", Namespace="http://www.unikum.se/pws")]
[System.SerializableAttribute()]
public partial class Item : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged {

    [System.NonSerializedAttribute()]
    private System.Runtime.Serialization.ExtensionDataObject extensionDataField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string ItemNoField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string StoreIDField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string NotInERPField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string DeliveryTimeTextField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private long DeliveryDaysField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private long InStockQtyField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string InShowRoomField;

    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private string PointsField;

    [global::System.ComponentModel.BrowsableAttribute(false)]
    public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
        get {
            return this.extensionDataField;
        }
        set {
            this.extensionDataField = value;
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
    public string ItemNo {
        get {
            return this.ItemNoField;
        }
        set {
            if ((object.ReferenceEquals(this.ItemNoField, value) != true)) {
                this.ItemNoField = value;
                this.RaisePropertyChanged("ItemNo");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
    public string StoreID {
        get {
            return this.StoreIDField;
        }
        set {
            if ((object.ReferenceEquals(this.StoreIDField, value) != true)) {
                this.StoreIDField = value;
                this.RaisePropertyChanged("StoreID");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)]
    public string NotInERP {
        get {
            return this.NotInERPField;
        }
        set {
            if ((object.ReferenceEquals(this.NotInERPField, value) != true)) {
                this.NotInERPField = value;
                this.RaisePropertyChanged("NotInERP");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=3)]
    public string DeliveryTimeText {
        get {
            return this.DeliveryTimeTextField;
        }
        set {
            if ((object.ReferenceEquals(this.DeliveryTimeTextField, value) != true)) {
                this.DeliveryTimeTextField = value;
                this.RaisePropertyChanged("DeliveryTimeText");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(Order=4)]
    public long DeliveryDays {
        get {
            return this.DeliveryDaysField;
        }
        set {
            if ((this.DeliveryDaysField.Equals(value) != true)) {
                this.DeliveryDaysField = value;
                this.RaisePropertyChanged("DeliveryDays");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(Order=5)]
    public long InStockQty {
        get {
            return this.InStockQtyField;
        }
        set {
            if ((this.InStockQtyField.Equals(value) != true)) {
                this.InStockQtyField = value;
                this.RaisePropertyChanged("InStockQty");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=6)]
    public string InShowRoom {
        get {
            return this.InShowRoomField;
        }
        set {
            if ((object.ReferenceEquals(this.InShowRoomField, value) != true)) {
                this.InShowRoomField = value;
                this.RaisePropertyChanged("InShowRoom");
            }
        }
    }

    [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=7)]
    public string Points {
        get {
            return this.PointsField;
        }
        set {
            if ((object.ReferenceEquals(this.PointsField, value) != true)) {
                this.PointsField = value;
                this.RaisePropertyChanged("Points");
            }
        }
    }

    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));
        }
    }
}

When asking for a specific item I get this result in Fiddler

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetStockResponse xmlns="http://www.unikum.se/pws">
<Items>
<Item>
<ItemNo>0000001234</ItemNo>
<DeliveryTimeText>4-6 veckor</DeliveryTimeText>
<DeliveryDays>42</DeliveryDays>
<Points>17</Points>
<StoreID>036</StoreID>
<NotInERP>Nej</NotInERP>
<InStockQty>4</InStockQty>
<InShowRoom>Nej</InShowRoom>
</Item>
</Items>
</GetStockResponse>
</soap:Body>
</soap:Envelope>

So long all looks good, right? How come that some fields are then null in the serialized result in the program that consumes the service? The fields looks like this:

  • DeliveryDays (works): 42
  • DeliveryTimeText (works): "4-6 veckor"
  • InShowRoom (doesn't work): null
  • InStockQty (doesn't work): 0
  • ItemNo (works): "0000001234"
  • NotInERP (doesn't work): null
  • Points (works): "17"
  • StoreID (doesn't work): null

Anyone got any pointers on what to look for when trying to debug this? Most of these fields have been working previously but one after another has stopped working, and I think it is related to changes in the service on the ERP side.

Since I'm not responsible for this part I'm trying to provide enough details on why this is not working when consuming it in C#. I mean since some fields works and the response in Fiddler looks ok it seems to be something in how the router is created and configured in C# based on the WSDL-information.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Hyzac
  • 475
  • 3
  • 16
  • post the definition of the Item type from the service side. – iamkrillin Jan 21 '15 at 15:46
  • It's in the first codeblock – Hyzac Jan 21 '15 at 15:52
  • that looks like the client side to me. – iamkrillin Jan 21 '15 at 15:54
  • the service side is a Pyramid system I don't have any access to. All I got is the WSDL information to base the service reference on. – Hyzac Jan 21 '15 at 16:00
  • Could it be something with the Order attribute value? [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)] two of the fields are lacking this and the other have it set. Does that make is expect the answer to be in a specific order? – Hyzac Jan 21 '15 at 16:05
  • It is definitely related to the Order parameter setting. Manually changed the Order information to match the one in the answer and got it to work with values on each field. Why is it set at all and how can I get it to be set correctly? – Hyzac Jan 21 '15 at 16:19
  • See http://stackoverflow.com/questions/5384254/svcutil-generates-order-named-parameter-for-xsdall-complexcontent – stuartd Jan 21 '15 at 16:47

1 Answers1

0

Ok, stuartd's comment provided more details about the issue and providing this to the Serviceprovider resulted in that they could rearrange the structure in their answer. This solved the issue and all data is deserialized correctly. Thanks for the input.

Hyzac
  • 475
  • 3
  • 16