2015-04-02 40 views
0

我遇到很大问题。Web服务响应中缺少对象 - c#

在地图阵列
/// <remarks/> 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18047")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://www.foo.com")] 
    public partial class FieldListType { 

     private MapTypeEntry[] mapField; 

     private string nameField; 

     /// <remarks/> 
     [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] 
     [System.Xml.Serialization.XmlArrayItemAttribute("Entry", typeof(MapTypeEntry), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)] 
     public MapTypeEntry[] Map { 
      get { 
       return this.mapField; 
      } 
      set { 
       this.mapField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlAttributeAttribute()] 
     public string Name { 
      get { 
       return this.nameField; 
      } 
      set { 
       this.nameField = value; 
      } 
     } 
    } 

    /// <remarks/> 
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18047")] 
    [System.SerializableAttribute()] 
    [System.Diagnostics.DebuggerStepThroughAttribute()] 
    [System.ComponentModel.DesignerCategoryAttribute("code")] 
    [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://www.foo.com")] 
    public partial class MapTypeEntry { 

     private string keyField; 

     private string valueField; 

     /// <remarks/> 
     [System.Xml.Serialization.XmlAttributeAttribute()] 
     public string Key { 
      get { 
       return this.keyField; 
      } 
      set { 
       this.keyField = value; 
      } 
     } 

     /// <remarks/> 
     [System.Xml.Serialization.XmlAttributeAttribute()] 
     public string Value { 
      get { 
       return this.valueField; 
      } 
      set { 
       this.valueField = value; 
      } 
     } 
    } 

我的问题是缺少对象: 这在reference.cs

[System.Web.Services.Protocols.SoapHeaderAttribute("SecurityValue")] 
    [System.Web.Services.Protocols.SoapHeaderAttribute("MessageHeaderValue")] 
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)] 
    [return: System.Xml.Serialization.XmlElementAttribute("TestResponse", Namespace="http:/test/Services")] 
    public TestResponse testRequest([System.Xml.Serialization.XmlElementAttribute("TestRequest", Namespace="http://Test.com/TestServices")] TestRequestTestRequest1) { 
     object[] results = this.Invoke("TestRequest", new object[] { 
        TestRequest1}); 
     return ((TestResponse)(results[0])); 

这是arrayitem(也是自动生成的)自动生成的方法。我已经通过Fiddler获得了网络响应的回应。作为响应,数组中有三个Map对象。 但在我的TestResponse代码中,我发现只有一个(最后一次尝试)对象。 我尝试了一些东西,但我仍然没有找到好的解决方案。

我在做什么错了?

回答

0

您需要确保XML标签在两端都使用相同的铸件进行访问。如果投射不同,则不会读取该值。

+0

这是从提琴手片段: ' \t \t \t \t \t \t \t \t \t \t \t <项键= “一键” 值= “1”/> \t \t \t \t \t \t <项键= “TwoKey” 值= “C”/> \t \t \t \t \t \t <项键= “ThreeKey” 值= “1”/> \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t <项键= “一键” 值= “123” /> \t \t \t \t \t \t \t \t \t \t \t \t <项键= “ThreeKey” VALUE = “123123”/> \t \t \t \t \t \t \t \t \t' 在阵列中只有与一键= 123最后地图对象。 – ogrod87 2015-04-02 10:25:02

+0

你需要检查你的服务返回的xml。它返回一个字符串,其中包含一个XML' – user01928374655647382910019283 2015-04-02 10:26:12

+0

我检查了Fiddler服务返回的内容。这就是我想要的。 – ogrod87 2015-04-02 10:27:02