即使服务器返回SOAP-ENV,也不会抛出SoapException:Fault

时间:2011-03-04 16:04:52

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

通常,如果webservice返回错误,则从SoapHttpClientProtocol派生的客户端代理会抛出异常。但我现在有这样的情况:服务器肯定会返回一个soap错误,客户端不会抛出异常,所以客户端无法知道调用是否成功(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>

1 个答案:

答案 0 :(得分:0)

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