Re: exception responses to ASP.Net soap services



The simple Hello World example
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.ComponentModel;

namespace WebService1
{
[WebService(Namespace = "http://tempuri.org/";)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
throw new SoapException("boo hoo", SoapException.ServerFaultCode,
"http://tempuri.org/HelloWorld";, new ApplicationException("Ha ha"));
return "Hello World";
}
}
}

produces :

HTTP/1.1 500 Internal Server Error
Server: ASP.NET Development Server/8.0.0.0
Date: Fri, 03 Oct 2008 16:25:39 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 250
Connection: Close

System.Web.Services.Protocols.SoapException: boo hoo --->
System.ApplicationException: Ha ha
--- End of inner exception stack trace ---
at WebService1.Service1.HelloWorld() in
C:\test\ConsoleApplication1\WebService1\Service1.asmx.cs:line 21

For example...

Thanks
Mark

"John Saunders" wrote:

"Mark" <mmodrall@xxxxxxxxxxxxx> wrote in message
news:982724F7-C98F-46E5-9963-FF7728907745@xxxxxxxxxxxxxxxx
Hi...

How does one get an exception in a SOAP method call to get returned as a
SOAP error packet? I found several articles online that seemed to imply
wrapping it in a SoapException should result in proper handling but that
doesn't appear to be the case.

Throwing a SoapException from a web service method just leads to an http
status of 500 and no output at all.

Is there support in the framework for returning a soap exception packet,
or
does one have to roll one's own?

Any uncaught exception is translated into a SOAP Fault. That should always
happen.

Please create and post a small piece of code that reproduces the situation
where an exception is not returned as a SOAP Fault?

--
John Saunders | MVP - Connected System Developer


.



Relevant Pages

  • RE: Global Exception Handling
    ... Exceptions thrown by an XML Web service method created using ASP.NET are ... sent back to the client in the form of a SOAP fault. ... XML element contains details such as the exception string and the ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • RE: Strange SOAP Exception
    ... details in the Detail element inside of a SOAP fault. ... want to do (since SOAP does not allow you to define new fault types), ... element of the exception before returning the exception. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Is this a valid SOAP fault response ..
    ... Is the following a valid SOAP Response for a SOAP Fault? ... not as an exception object. ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: SoapExtension doesnt work with HttpGet
    ... The SoapExtension capability exposes the parsing and formatting of SOAP ... HttpGet, then the extension never gets activated. ... will get invoked in the case of an unhandled application exception. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: SoapExtension doesnt work with HttpGet
    ... HttpGet too saying it will used 80% of the time rather than SOAP!! ... > Summary of Http Handlers and Http Modules in ASP.NET ... > will get invoked in the case of an unhandled application exception. ...
    (microsoft.public.dotnet.framework.webservices)

Loading