First, I'll say I am not making this up. I have a web method implemented in a asmx file like this:
[WebMethod]
[SoapDocumentMethod(OneWay=true)]
public void Method1(INPUT oInput)
{
// Call SQL stored procedure SP1
// Call SQL stored procedure SP2
}
Using SQL Server Profiler I see stored SP1 get called, but SP2 does not. If I set OneWay=false, both SP1 and SP2 get called.
Here's the weird part. I leave OneWay=true but I set <trace enabled="true">
over in the web config file, both SP1 and SP2 get called. No really!
I will try posting more sample code after I par it down to the minimums. In the mean time, does anyone know of a bug in ASP.NET 3.5 SP1 that might be causing this?
Charles
-
According to this article, the impersonation context from web.config disappears when OneWay=true. Is it possible that the security is slightly different on the two SPs?
Charles : I'll investigate, but I'm suspecting this is not the cause. I'm using SQL server authentication with a connection string like "server=Server;database=Database;uid=User;pwd=Password". It seems the running ASP.NET thread context would have no effect when accesses SQL this way. -
I found my own answer. There was some code between SP1 and SP2 that accesses the Context.Current.Request object. Commenting it out fixes my issue.
Conclusion? It seems the Request object is unavailable if OneWay=true. Strange though that setting
<trace enabled="true">
makes the object available.From documentation of OneWay property:
Do not have access to HttpContext using the static Current property. To access the HttpContext, derive the class implementing the XML Web service method from WebService and access the Context property.
Moose : That makes sense -- when OneWay=true, the Response is returned before your WebMethod is even kicked off. Glad you figured it out.
0 comments:
Post a Comment