Throwing a SoapException does not return a valid SOAP response

I am working on an old website. It calls the ASP.Net web service (old .asmx files). Whenever an exception occurs in a web service, it throws a SoapException. The client catches this exception, but cannot separate it.

I am viewing the SOAP request and response using Fiddler and the SOAP UI and reading this article http://msdn.microsoft.com/en-us/library/aa480514.aspx I expect to receive a response in the following format:

<soap:Fault>
<faultcode>soap:Server</faultcode>    
<faultstring>Server was unable to process request. Something bad happened</faultstring>
<detail />

However, I just get the following answer:

HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/10.0.0.0
Date: Thu, 12 Jun 2014 05:27:14 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 164
Connection: Close

System.Web.Services.Protocols.SoapException: Something bad happened
   at WebService1.Service1.HelloWorld() in ...

I believe that the client cannot handle the exception.

This happens even in the Hello World web service.

What could be wrong?

UPDATE: -, , :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ords="http://mydomain.com/">
   <soapenv:Header/>
   <soapenv:Body>
      ...
   </soapenv:Body>
</soapenv:Envelope>

SoapException:

[WebMethod]
public string HelloWorld()
{
     throw new SoapException("Something bad happened", SoapException.ClientFaultCode);
     //return "Hello World";
}
+4
1

httpHandlers web.config -, . , XML SOAP .

0

Source: https://habr.com/ru/post/1544275/


All Articles