Log SOAP Messages with a SOAP Extension

Problem

You want to directly access or modify raw SOAP messages with .NET code.

Solution

Create a custom SOAP extension.

Discussion

ASP.NET allows you to access the raw SOAP messages that are transmitted to and from a Web service, but only by creating a special SOAP extension class. This class is triggered automatically as the SOAP message passes through the following four stages on the server:

  • SoapMessageStage.BeforeDeserialize occurs immediately after the Web server receives the SOAP request message.

  • SoapMessageStage.AfterDeserialize occurs after the raw SOAP message is translated to .NET data types but just before the Web method code runs.

  • SoapMessageStage.BeforeSerialize occurs after the Web method code runs ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.