Web服务请求返回null

我试图调用托管在java服务器上的Web服务。 我通过Visual Studio提供的Web服务创建工具创建了类。 当我调用该方法时,我可以在Fiddler中看到它正在返回有效数据。 但是,在我的C#代码中,我的结果为null。

任何帮助,将不胜感激。

C#调用代码:

RuleValidationResponseRule[] ruleResponse = rulesWebService.RuleValidation(ruleData, "LO"); 

Web Service生成的代码:

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.example.org/LathamInt/RuleValidation", RequestNamespace="http://www.example.org/LathamInt/", ResponseNamespace="http://www.example.org/LathamInt/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] [return: System.Xml.Serialization.XmlArrayAttribute("ruleValidationResp", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] [return: System.Xml.Serialization.XmlArrayItemAttribute("rule", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)] public RuleValidationResponseRule[] RuleValidation([System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] RuleValidationRuleData ruleData, [System.Xml.Serialization.XmlAttributeAttribute()] string company) { object[] results = this.Invoke("RuleValidation", new object[] { ruleData, company}); return ((RuleValidationResponseRule[])(results[0])); } 

XML传递给webservice(来自Fiddler):

            

从服务返回的XML(来自Fiddler):

         3" post="3 > 3"/>      

C#生成代码中的响应定义:

 ///  [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://www.example.org/LathamInt/")] public partial class RuleValidationResponseRule { private RuleValidationResponseRuleExpression expressionField; private string resultField; private string ruleIdField; private string statusField; ///  [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public RuleValidationResponseRuleExpression expression { get { return this.expressionField; } set { this.expressionField = value; } } ///  [System.Xml.Serialization.XmlAttributeAttribute()] public string result { get { return this.resultField; } set { this.resultField = value; } } ///  [System.Xml.Serialization.XmlAttributeAttribute()] public string ruleId { get { return this.ruleIdField; } set { this.ruleIdField = value; } } ///  [System.Xml.Serialization.XmlAttributeAttribute()] public string status { get { return this.statusField; } set { this.statusField = value; } } } 

我相信我已经解决了。

在返回XML中,这一行

  

表示返回标记没有命名空间。 它需要改为

  

要么是,要么修改线

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute ("http://www.example.org/LathamInt/RuleValidation", RequestNamespace="http://www.example.org/LathamInt/", ResponseNamespace="http://www.example.org/LathamInt/", //<-- ** Change this line Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] 

 [System.Web.Services.Protocols.SoapDocumentMethodAttribute ("http://www.example.org/LathamInt/RuleValidation", RequestNamespace="http://www.example.org/LathamInt/", ResponseNamespace="", //<-- ** Change this line Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]