2010-11-23 72 views
0

我在发送SOAP请求到一个web服务的问题。我创建了一个订单,其中包含一系列订单详细信息。然后我将该订单发送给web服务。使用fiddler,我可以看到订单正确传递,但订单详细信息不显示。我只得到:C#故障排除对象序列化错误

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

我试图改变ORDERDETAILS从订单详情数组字符串数组和他们正确地显示在该请求。我也得到正确的订单号码。他们只是空的。从WSDL生成

两个类,所以我不知道为什么的OrderDetail似乎并没有被正确序列化。我不知道如何获得更多的错误细节。任何帮助将不胜感激。由于

从我的Reference.cs,从我的web服务生成:

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

}

+0

对不起,经过进一步研究,这个问题可能会更简单。基本上我可以序列化订单对象,但序列化orderDetails对象只是返回一个空对象。他们似乎被宣布为同样的方式,所以我不知道是否有人知道为什么会发生这种情况,或者我可以如何调试序列化过程。 – Tavis 2010-11-23 16:21:14

回答

2

好像生成的类必须为每个字段 '指定' 字段。

设置

object.productIDSpecified=true; 

制造它正确序列化。希望这可以帮助别人。