Sunday, March 04, 2007

Intro to SOAP Headers in C#

Let's learn how to manipulate SOAP Headers in .NET C# with a simple web service producer-consumer example. .NET Framework SDK provides a sample producer that receives a SOAP Request with Header information, gets a handle on the Header and returns information from the Header as a part of the SOAP Response. To get familiar with manipulating SOAP Headers let's walk you through the steps on loading this in Web Matrix.

  1. Get familiar with building simple web services in .NET. See Building and Testing your First Web Service in .NET
  2. Download the C# SOAP Header sample from here.
  3. Start a web services project in ASP .NET Web Matrix and copy the sample C# SOAP Header code from Step 2 above into the editor. See figure below.
  4. Hit the save button and then the start button. This will bring up the browser with the service description. The WSDL file will be available at a location similar to http://localhost:9090/SOAPHeaders.asmx?WSDL (depending on your port setting and .asmx file name in Web Matrix). See Step 1 example.
  5. You can now load the WSDL is a SOA Testing Tool that is SOAP Header aware. SOAPSonar is one such flexible SOA Testing Tool that you can download from Crosscheck Networks.
  6. Load the WSDL into SOAPSonar. The parsed WSDL shown below has a header and a body inputs. Entering values for the Headers and Body results in a SOAP response from the SecureMethod.

Testing SOAP Headers requires test tools to properly parse WSDL and generate input fields for the SOAP Headers. SOAPSonar enables developers and testers to do this easily. With full SOAP Header control, you can now build authentication, routing, audit, and security schemes right into the header. It is strongly advised that standards-based header content is used and customization for header be restricted for maximum interoperability.

No comments: