Tavis
Tavis

Reputation: 97

C# Troubleshooting object serialization error

I'm having problems sending a soap request to a webservice. I create an order, including an array of order details. Then I send that order to the webservice. Using fiddler, I'm able to see that the order gets passed correctly, but the order details don't show up. I only get:

<order><orderDetails><orderDetail /></orderDetails><order>

I've tried changing orderDetails from an array of order details to an array of strings and they show up correctly in the request. I also get the correct number of in the order. They're just empty.

Both classes were generated from the wsdl, so I don't know why orderDetail doesn't seem to be serializing properly. I don't know how to get more error details. Any help would be greatly appreciated. Thanks

From my Reference.cs, generated from my web service:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://some.url")]
public partial class order {
    private orderDetail[] orderDetailsField;

    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    [System.Xml.Serialization.XmlArrayItemAttribute("orderDetails", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public orderDetail[] orderDetails {
        get {
            return this.orderDetailsField;
        }
        set {
            this.orderDetailsField = value;
        }
    }
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://some.url")]
public partial class orderDetail {
    private int productIDField;

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
    public int productID {
        get {
            return this.productIDField;
        }
        set {
            this.productIDField = value;
        }
    }

}

Upvotes: 0

Views: 1448

Answers (1)

Tavis
Tavis

Reputation: 97

Seems like the generated classes have a 'Specified' field for each field.

Setting

object.productIDSpecified=true;  

Made it serialize properly. Hopefully this helps someone else out.

Upvotes: 2

Related Questions