how to catch exceptions from one-way (fire and forget) ASP.NET webservice call
I am calling a ASP.NET webservice which is marked as one-way. I wrapped the code that calls the web service in a tr开发者_如何学编程y catch block, but it is not catching the exceptions thrown by the web service. when I test the webservice separately by entering the url in the browser, it throws an error, but the exception is not sent to the calling code for some reason. here is the sample code
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://mycompany.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class TestWebService : System.Web.Services.WebService
{
[SoapDocumentMethod(OneWay = true)]
[WebMethod(Description="Start a long running process.")]
public void LongRunningProcess()
{
//do some long process
}
}
//calls proxy class method
TestWebService testWebService = new TestWebService();
testWebService.Timeout = Timeout.Infinite;
testWebService.Credentials = CredentialCache.DefaultCredentials;
testWebService.Url = <url> //the web service url
testWebService.LongRunningProcess()
any help would be appreciated.
I don't believe you can.
The whole point of stating a method is one way is to mark it as a fire-and-forget, the client does not have to wait for the method to be invoked.
As soon as the server parsed the request, and often before it actually invokes the method, it returns http 202, at which point the client moves on.
精彩评论