Re: HttpModules - Webservices



Bruce:

The Application.Lock would make me nervous. It does look as if you
have an Unlock at the right places, but you might consider using a
finally clause. I'd

When the application blocks can you break in with the debugger and
look at call stacks for all the threads? That might show you how the
application became deadlocked.

--
Scott
http://www.OdeToCode.com/blogs/scott/


On Wed, 11 May 2005 20:30:57 +0100, "Bruce Hodge"
<support@xxxxxxxxxxxxxxxxxx> wrote:

>Hi,
>
>We have a couple of clients who are having trouble connecting to .Net
>webservices, (they're coming from PHP and VFP). We were looking to provide
>a diagonostic tool that displayed the soap message submitted so that if the
>call failed they could compare their SoapMessage with the ones we generate
>in .Net.
>
>Thought the solution was an HttpModule hooked into begin request, but after
>approx 10 requests it hangs the webservice/aspnet service, any thoughts?
>Code below.
>
>(The HttpRequests are stored in Typed Dataset, stored on the Application
>object so that they can be accessed from webpages.)
>
>
>public void OnBeginRequest(Object s, EventArgs e)
>{
> try
> {
> // Cast the Object to the HttpApplication variable.
> HttpApplication app = (HttpApplication)s;
>
> HttpRequest newRequest = app.Request;
>
> string servers = this.ServicesToMonitor();
> int posn =
>servers.ToLower().IndexOf(this.GetServiceName(newRequest).ToLower());
>
> if (posn > -1)
> this.AddFromHttpRequest(this.RequestHistory, newRequest);
>
> }
>
> catch (Exception ex)
> {
> //Custom error logging code
> }
>
>}
>
>private void AddFromHttpRequest(Mars.Schema.HttpRequests history,
>HttpRequest request)
>{
> try
> {
> HttpContext.Current.Application.Lock();
>
> byte [] byteArray = new byte[request.ContentLength];
>
> request.InputStream.Read(byteArray, 0, request.ContentLength);
>
> // Must reset the Input Stream position or the whole process fails.
> request.InputStream.Position = 0;
>
> Mars.Schema.HttpRequests.RequestsRow row =
>this.RequestHistory.Requests.AddRequestsRow(
>
>
> request.RawUrl,
> request.HttpMethod,
> request.ContentType,
> request.ContentLength,
> Encoding.ASCII.GetString(byteArray, 0, request.ContentLength),
> DateTime.Now,
> this.GetServiceName(request),
> this.SOAPAction(request),
> request.ServerVariables["REMOTE_ADDR"]);
>
> foreach (string s in request.Headers.AllKeys)
> this.RequestHistory.HttpHeaders.AddHttpHeadersRow(row.RequestID,
>s, request.Headers[s]);
>
> while (this.RequestHistory.Requests.Count > this.HistorySize)
> {
> this.RequestHistory.Requests[0].Delete();
> }
>
> this.RequestHistory.AcceptChanges();
>
> HttpContext.Current.Application.UnLock();
>
> }
>
> catch (Exception ex)
> {
>
> #region Catch Block
>
> #endregion
>
> HttpContext.Current.Application.UnLock();
>
> }
>
>}

.



Relevant Pages

  • Re: The namespace, , is a duplicate error when compiling .NET Webservice
    ... Please post the entire exception, complete with stack trace and inner ... the current web request. ... mapping, String ns, Boolean isAny, XmlSchemaElement element) +762724 ... type, HttpContext context, HttpRequest request, HttpResponse response, ...
    (microsoft.public.dotnet.framework.aspnet)
  • WSE 3.0 MTOM Problems
    ... An unhandled exception has occurred. ... Request URL: http://localhost:1497/WebService/AttachmentServices.asmx ... HttpContext context, HttpRequest request, HttpResponse response, Boolean& ... Then I get another one from WSE 3.0 in the Event Log ...
    (microsoft.public.dotnet.framework.webservices)
  • Problems with MTOM and WSE 3.0
    ... An unhandled exception has occurred. ... Request URL: http://localhost:1497/WebService/AttachmentServices.asmx ... HttpContext context, HttpRequest request, HttpResponse response, Boolean& ... Then I get another one from WSE 3.0 in the Event Log ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • HttpModules - Webservices
    ... webservices,. ... Thought the solution was an HttpModule hooked into begin request, ... public void OnBeginRequest ... catch (Exception ex) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: HttpModules - Webservices
    ... eyeball the request/response from a client machine and see if there ... >Thought the solution was an HttpModule hooked into begin request, ... >public void OnBeginRequest ... > catch (Exception ex) ...
    (microsoft.public.dotnet.framework.aspnet)