Home > Microsoft .Net Development Tips > ASP.NET Development > Understand SOAP extensions
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ASP.NET DEVELOPMENT

Understand SOAP extensions


Bob Tabor
10.16.2002
Rating: -4.33- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In the previous tip, we discussed DiffGrams and I showed what a DiffGram looked like in its native habitat. Since these creatures only come out under the cover of a SOAP message (and are therefore too fast for humans to see with the naked eye) we need a tool to capture a snapshot picture of what a SOAP message looks like during transfer between client and server. To do this, we're going to take a brief detour and talk about how ASP.NET works so we can then explain how SOAP Extensions will allow us to plug into and capture the SOAP stream before (or after) it gets transformed into an object that is processed by your Web Service code, and also capture the objects before (or after) they are transformed back into an outgoing SOAP message.

Consider the following diagram:

In this diagram, note how a request for an ASP.NET page (we'll say, a ASP.NET Web services page with an asmx file extension) is made to IIS. IIS recognizes this file extension and hands off the message to the .NET ISAPI object, which then sends the message down the call chain for Web services. The call chain consists of zero to many HTTP Modules that have been configured to be used for Web services. HTTP Modules are pluggable extensions that allow you to intercept the incoming or outgoing messages from your applications. You could use this to provide encryption/decryption, logging, etc. Finally, after the last HTTP Module is satisfied, the message is routed to the appropriate HTTP Handler that knows how to take care of aspx files. It provides the context and performs the logic of your particular application, then knows how to send a message back up the call chain. The message goes through the HTTP Modules, to IIS and is then routed back to the client.

The HTTP Handler for Web Services provides SOAP Extensions, which basically allow you one more opportunity to intercept the messages before or after they are handled by the HTTP Handler and your application's logic. SOAP extensions allow you to plug into the .NET Framework's SOAP architecture to perform some pre- or post-processing on SOAP messages. When the Web service's HTTP Handler receives a SOAP message, the SOAP message is de-serialized into objects (for example, SoapHeader objects or SoapMessage objects) and eventually passed into your Web method. Then after your Web method has finished, the result, as well as any SoapHeader objects or SoapException objects, are serialized into a SOAP message and sent back up the chain and to the client.

However, you can hook into the request chain before and after the SOAP message is de-serialized into objects, and after the Web method has finished processing and the objects are serialized back into SOAP messages.

When working with extensions, there are four "stages":

  • BeforeDeserialize - This stage occurs before the SOAP message is de-serialized into objects and sent to the requested Web Service. Therefore, you still have access to the actual SOAP message.

  • AfterDeserialize - This stage occurs after the SOAP message is de-serialized into objects and sent to the requested Web services, so you now have access only to the objects that represent the SOAP message, such as the SoapHeader object and the SoapMessage object.

  • Before Serialize - This stage occurs after the Web service has finished processing and before the returned objects are serialized back into a SOAP message and sent to the client. Therefore, you still have access to all the objects that will ultimately be serialized into a SOAP message.

  • AfterSerialize - This stage occurs after the Web service has finished processing and after the returned objects are serialized back into a SOAP message and sent to the client, so you now have access to the SOAP message being sent back to the client.

You might be wondering how SOAP extensions differ from HTTP Modules. First, you can selectively place SOAP extensions on certain Web methods, and ignore other ones, which is much more difficult to do with HTTP Modules. Second, you can access the de-serialized objects in the AfterDeserialize and BeforeSerialize stages, but you cannot access these objects in HTTP Modules; HTTP Modules allows you to see only the SoapMessage object, and little else. Third, it is easier to modify values before and after the Web method has processed the request by using extensions instead of HTTP Modules. HTTP Modules still serve a purpose however. It is just a matter of selecting the right tool for the job, so it's important to understand when to use each tool.

So now that I got you all excited about SOAP Extensions, I'm going to make you wait until the next tip to see the SOAP Extension in action because it is a pretty advanced feature of .NET and the code will require quite a bit of explanation. Stay tuned.



About the Author

Robert Tabor is a Microsoft Certified Professional in Visual Basic with over six years of experience developing n-tier Microsoft-centric applications for some of the world's most prestigious companies and consulting organizations, such as Ernst & Young, KPMG, Cambridge Technology Partners, Sprint, American Heart Association, and the Mary Kay Corporation. Bob is the author of Microsoft .NET XML Web services by Sams Publishing, and contributes to SoapWebservices.com and LearnVisualStudio.NET. He is currently working on initiatives within Mary Kay, the second largest eCommerce site in retail volume on the net, of how to utilize .NET within their e-business group.

Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
ASP.NET Development
How to use jQuery to solve Javascript browser compatibility problems
How to write an out-of-browser Silverlight 3 application in 3 steps
Silverlight 3 beta SDK download lets developers try new RIA features
Visual Studio's IntelliSense for jQuery doesn't autocomplete correctly
Dundas Map for .NET kicks up geographic visualization
Return to CodePlex: Into the Sandcastle…
VBScript Tutorial
Use PHP with Visual Studio to create Web sites
Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
Visual Studio 2008 and .NET Framework 3.5 SP1 introduces ADO .NET Entity Designer

Web services and SOA implementations in the .NET Framework
Goin' mobile with Windows
Microsoft "WebSphere Loves Windows" ads tout cost, performance vs. AIX
Microsoft releases new CTP of Oslo SDK
Microsoft's Oslo modeling platform, the M language and .NET
Outgoing Bill Gates says UML on tap in Oslo SOA modeler
Podcast: Windows CardSpace authors speak
Open XML SDK ready for the road
Some of the Zen of Volta
Scaling WCF applications can challenge development teams
Security interoperability with .NET/WSE and WebLogic Workshop 8.1

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
scripting language  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts