Where'd my exception go?

Say you have a WebMethod and a SoapMethod that look like this:

 

[WebMethod]

public void Void(string s)

{       

      throw new Exception("blah");

}

 

[SoapMethod("Void")]

public void Void(string s)

{

      throw new Exception("blah");

}

 

If you call both with generated proxies, the WebMethod call throws an exception but the SoapMethod doesn't.  What gives?  It turns out a SoapMethod that returns void is always one way, but the WebMethod isn't.  To make a WebMethod one way you can apply one of these attributes:

 

[SoapDocumentMethod(OneWay=true)] or

[SoapRpcMethod(OneWay=true)]

 

If you don't want the SoapMethod to be one way, change it so it returns an empty envelope.