Web服务请求返回null [英] web service request is returning null

查看:136
本文介绍了Web服务请求返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调用托管Java服务器上的Web服务。我已经通过提供与Visual Studio的Web服务创建工具创建的类。当我调用该方法,我可以小提琴手看到它返回的有效数据。然而,在我的C#code,我的结果为空。

I am attempting to call a web service that is hosted on a java server. I have created the classes through the web service creation tool provided with Visual Studio. When I call the method, I can see in Fiddler that it is returning valid data. However, in my C# code, my result is null.

任何帮助将是AP preciated。

Any help would be appreciated.

C#调用code:

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

Web服务产生code:

Web Service generated code:

传递给web服务(从提琴手)XML

XML passed to the webservice (from Fiddler):

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <RuleValidation company="LO" xmlns="http://www.example.org/LathamInt/">
            <ruleData xmlns="">
                <rule ruleID="GDSP" />
                <varData varName="GuideSpace" varValue="3" />
            </ruleData>
        </RuleValidation>
    </soap:Body>
</soap:Envelope>

从XML(从提琴手)服务返回

<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:lat="http://www.example.org/LathamInt/"> <soapenv:Header/> <soapenv:Body> <RuleValidationResponse> <ruleValidationResp> <rule result="0" ruleId="GDSP" status="success"> <expression pre="@GuideSpace > 3" post="3 > 3"/> </rule> </ruleValidationResp> </RuleValidationResponse> </soapenv:Body> </soapenv:Envelope>

Response definition in C# generated code:

在C#

响应定义生成code:

/// <remarks/> [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; /// <remarks/> [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public RuleValidationResponseRuleExpression expression { get { return this.expressionField; } set { this.expressionField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string result { get { return this.resultField; } set { this.resultField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string ruleId { get { return this.ruleIdField; } set { this.ruleIdField = value; } } /// <remarks/> [System.Xml.Serialization.XmlAttributeAttribute()] public string status { get { return this.statusField; } set { this.statusField = value; } } }


推荐答案

我相信我已经解决了。

在返回的XML,此行

<RuleValidationResponse>

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

means the return tag does not have a namespace. It needs to be changed to

<lat:RuleValidationResponse>

如果不是这样,或者修改该行

Either that, or modify the line

[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)]

这篇关于Web服务请求返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆