2

我正在编写的 Web 服务出现问题(它是 asmx)。

我有这个方法:

    [WebMethod()]
    [SoapDocumentMethod(
        RequestNamespace="http://bsp.XXX.org",
        ResponseNamespace="http://bsp.XXX.org",
        ResponseElementName="PaymentResults",
        RequestElementName="GetPaymentResult",
        Action = "http://bsp.XXX.org/GetPaymentResult")]
    public PaymentResult[] GetPaymentResult(string MerchantRef)
    {
        try
        {
            if (!String.IsNullOrEmpty(MerchantRef))
            {
                return PaymentResultRepository.GetPaymentResults(MerchantRef).ToArray();
            }
            else
            {
                _errorLog.Error("MerchantRef is empty");
            }
        }
        catch (Exception ex)
        {
            _errorLog.Error("Failed to get payment details", ex);
        }
        return new PaymentResult[0];
    }
}

它是从 Oracle Forms 应用程序中调用的。收到的 SOAP 请求是:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    <SOAP-ENV:Body>
        <GetPaymentResult xmlns="http://bsp.XXX.org/" 
                 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            <MerchantRef xsi:type="xsd:string">
                 IP/58991/1
            </MerchantRef>
        </GetPaymentResult>
    </SOAP-ENV:Body>

问题是“MerchantRef”在我的方法中始终是一个空字符串......有人对此有任何想法吗?SOAP 请求是否错误?我错过了一些明显的东西吗?

4

1 回答 1

2

原来问题是SOAP请求......

它不喜欢 encodingStyle 属性,一旦删除它就可以完美运行。

即由此:

<GetPaymentResult xmlns="http://bsp.XXX.org/" 
             SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

到:

<GetPaymentResult xmlns="http://bsp.XXX.org/">
于 2012-11-02T11:52:24.093 回答