Creating SOAP Header Schemas in BizTalk 2006 (Part 2)

First, we have to know, how to Build a web service That Processes SOAP Headers:

---Define and Process SOAP Headers:

1. To define a class representing a SOAP header
-Create a class deriving from the Soap Header class with a name matching the root element for the SOAP header. Then Add public fields or properties, matching the names and their respective data types for each element in the SOAP header. For instance, given the following SOAP header, the class following it defines a class representing the SOAP header.

public class mySoapHeader : SoapHeader
{
public string HeaderValue;
}
2. To process SOAP headers within a Web service
-Add a public member to the class implementing the Web service of the type representing the SOAP header.


[WebService(Namespace = "http://ITWorx/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public mySoapHeader MyHeaderValue;

}
- Apply a
SoapHeader attribute to each Web service method that intends to process the SOAP header. Set the MemberName property of the SoapHeader attribute to the name of the member variable created in the first step.

[SoapHeader("MyHeaderValue",Direction=SoapHeaderDirection.In)]
public string GetString()
{
}

-Within each Web service method that the SoapHeader attribute is applied to, access the member variable created in the first step to process the data sent in the SOAP header.

[SoapHeader("MyHeaderValue",Direction=SoapHeaderDirection.In)]
public string GetString()
{
if (MyHeaderValue != null){
return MyHeaderValue.HeaderValue;
}
else
return "Invalid information in SOAP Header";

In the Next article in sha'a ALLAH, I will explain how the orchestration could send a request includes a custom value in the SOAP Header



0 Response to "Creating SOAP Header Schemas in BizTalk 2006 (Part 2)"