Server-Side Async Web Methods call fails

Discussion in 'ASP .Net Web Services' started by altialex, May 18, 2004.

  1. altialex

    altialex Guest

    Hi.
    I have WS implementing DIME 1.0. Primary client is ASP.NET Web application
    consuming WS through proxy.
    I though it might be beneficial from the performance stand point to
    implement some WS methods asynchronously. I've read msdn article "Server
    side Asynchronous Web Methods"
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnservice/html/service10012002.asp
    and basically copied the sample into my WS.
    public delegate string DummyAsyncStub(int milliseconds);
    public class DummyAsyncState {
    public object previousState;
    public DummyAsyncStub asyncStub;
    }
    internal string myLengthyProcedure(int milliseconds) {
    System.Threading.Thread.Sleep(milliseconds);
    return "Success";
    }
    [WebMethod]
    public System.IAsyncResult BeginLengthyProcedure(int milliseconds,
    System.AsyncCallback cb, object s) {
    DummyAsyncState ms = new DummyAsyncState();
    ms.previousState = s;
    ms.asyncStub = new DummyAsyncStub(myLengthyProcedure);
    return ms.asyncStub.BeginInvoke(milliseconds, cb, ms);
    }
    [WebMethod]
    public string EndLengthyProcedure(System.IAsyncResult asyncResult) {
    DummyAsyncState ms = (DummyAsyncState)asyncResult.AsyncState;
    return ms.asyncStub.EndInvoke(asyncResult);
    }
    After I call LengthyProcedure through the proxy I get an exception:

    System.Web.Services.Protocols.SoapException: Server was unable to process
    request. ---> System.NullReferenceException: Object reference not set to an
    instance of an object.
    at Microsoft.Web.Services.SoapEnvelope..ctor(SoapContext context)
    at
    Microsoft.Web.Services.WebServicesExtension.AfterSerializeServer(SoapMessage
    message)
    at Microsoft.Web.Services.WebServicesExtension.AfterSerialize(SoapMessage
    message)
    at Microsoft.Web.Services.WebServicesExtension.ProcessMessage(SoapMessage
    message)
    at
    System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[]
    extensions)
    at System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[]
    returnValues, Stream outputStream)
    at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
    returnValues)
    at System.Web.Services.Protocols.WebServiceHandler.EndInvoke(IAsyncResult
    asyncResult)
    --- End of inner exception stack trace ---

    I'm pretty much baffled about what I did wrong? Is DIME 1.0 relevant in this
    case for some reason?
    The funny thing is that the same method call completes without a hitch if
    consumed by Java (Axis) client.
    Can anyone help me?
     
    altialex, May 18, 2004
    #1
    1. Advertising

  2. altialex

    altialex Guest

    Never mind. Found the answer in webservices.enhancements newsgroup.
    "HttpContext.Current = this.Context ad the end of async method call." in
    case some1 else's wondering about this.
    Regards, Alex

    "altialex" <> wrote in message
    news:%...
    > Hi.
     
    altialex, May 18, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page