【问题标题】:No SoapException thrown even if server returns SOAP-ENV:Fault即使服务器返回 SOAP-ENV:Fault,也不会抛出 SoapException
【发布时间】:2011-03-04 16:04:51
【问题描述】:

如果 Web 服务返回错误,从 SoapHttpClientProtocol 派生的客户端代理通常会抛出异常。但是我现在有这样的情况,服务器最终返回一个肥皂错误,客户端没有抛出异常,所以客户端无法知道调用是否成功(webservice没有返回类型)。

什么可能导致这种行为?

这是服务器返回的内容:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Date: Fri, 04 Mar 2011 15:57:32 GMT
Server: Apache/2.0.52 (Unix) mod_ssl/2.0.52 OpenSSL/0.9.8m DAV/2
Last-Modified: Fri, 04 Mar 2011 15:57:32 GMT
Content-Length: 602
Vary: Accept-Encoding
Connection: close
Content-Type: text/xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
      <SOAP-ENV:Body>
         <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Server</faultcode>
            <faultstring>HDHPSPRT2</faultstring>
            <detail>HDHPSPRT2</detail>
         </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
   </SOAP-ENV:Envelope>

【问题讨论】:

    标签: .net web-services soap exception-handling


    【解决方案1】:

    您的服务违反了 SOAP 协议。故障必须以 4xx 或 5xx HTTP 状态码的形式返回。

    【讨论】:

    • 我们在服务器端使用 gSOAP。图书馆不应该为我们管理这种东西吗?
    • @codymanix:我会说它应该处理它,而且它显然不处理它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 2021-01-13
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 1970-01-01
    相关资源
    最近更新 更多