.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Get ASMX Response in Application events within Custom HttpModule.
 

Get ASMX Response in Application events within Custom HttpModule.

I have written a custom httpModule for web service plumbing feature. It means the plumbing class will log the request details and also the response details. Its like suppose we have a web service to get the customer nameaccording to the customer id; so the input to the web service is customer id and output would be customer name. I generally call the web service through URL and pass this customerid in my querystring. In my httpModule, I can get the customerid easily in Application_BeginRequestbecause I pass this as querystring. But I face problem when I try to get the response in Application_EndRequest.
Suppose I pass the customerid as http://xxx/WS.asmx/getCustomerName?sCustomerID=000000and the output is <string xmlns="xxxxx">TBD</string>. Now I need this xml string <string xmlns="xxxxx">TBD</string> in my Application_EndRequest through Response object. I bet that Response object should have this xml string but I dont know how to get that. I dont know whether I make you clear about my problem. If not, please let me know. Is there any way to get the response in httpModule.
Subhendu De
  • Moved byJohn SaundersMVPSaturday, September 19, 2009 5:49 PMWCF Question (From:ASMX Web Services and XML Serialization)
  •  
subhendude

Hi Subhendu,

As for ASP.NET ASMX webservice, for http get scenario, SoapExtension does not work. I haven't tested yet, but onething you can have a look is the "HttpResponse Filter" which can let you intercept the response stream(underlying binary data). You can try to see whether you can attach a custom filter in HttpModule's begining

#HttpResponse..::.Filter Property
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx

As for WCF, you can use MessageInspector to inspect or modify underlying soap message. Here are some reference articles about WCF Message Inspector:

#Message Inspectors
http://msdn.microsoft.com/en-us/library/aa717047.aspx

#Writing a WCF Message Inspector
http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Marked As Answer bysubhendude Wednesday, September 23, 2009 12:51 PM
  •  
Steven Cheng - MSFT
Look into the SoapExtension class instead of HttpModule's when working with ASMX web services.

Better yet, consider that Microsoft now considers ASMX to be "legacy technology" and use WCF instead.

John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
John Saunders
yes, soapextension comes into action when I add the service using web reference in my project. But I call the web service using HTTP GET url calling as I mentioned in my post. If I call this using URL then SoapExtension doesn't work. Is there any other way. How can I accomplishthe thing if I use WCF?
Subhendu De
subhendude
You'll need to ask on the WCF forum, so I'll move the question there. There's no other way to do that with ASMX web services.


John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
John Saunders

Hi Subhendu,

As for ASP.NET ASMX webservice, for http get scenario, SoapExtension does not work. I haven't tested yet, but onething you can have a look is the "HttpResponse Filter" which can let you intercept the response stream(underlying binary data). You can try to see whether you can attach a custom filter in HttpModule's begining

#HttpResponse..::.Filter Property
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx

As for WCF, you can use MessageInspector to inspect or modify underlying soap message. Here are some reference articles about WCF Message Inspector:

#Message Inspectors
http://msdn.microsoft.com/en-us/library/aa717047.aspx

#Writing a WCF Message Inspector
http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Marked As Answer bysubhendude Wednesday, September 23, 2009 12:51 PM
  •  
Steven Cheng - MSFT
Thanks Steven... I have reviewed the post and found a solution.
Subhendu De
subhendude

You can use google to search for other answers

Custom Search

More Threads

• MethodNameAsync web service calls in asp.net 2
• WCF issue with .Net 3.5 SP1 upgrade.. Authentication failure when Windows authentication is used over certain transports
• IndexOutOfRangeException from MessageSecurityOverHttpElement class of System.ServiceModel.dll
• WCF Performence Tuning
• Call WCF from javascript in diferent domain
• Problems understanding how to use the async loop in a ChannelListener while using a ServiceHost
• Monitoring client state
• secure WCF service with certificate
• Is there a way to find out which endpoint is being used by the client?
• WCF Client, WSIT Service, UsingAddressing