Server-Side Async Web Methods call fails

A

altialex

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?
 
A

altialex

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top