Listing 1

<webServices>
<soapExtensionTypes>
<add 
type="Microsoft.Web.Services.WebServices
Extension, 
Microsoft.Web.Services, 
Version=2.0.0.0,Culture=neutral, 
PublicKeyToken=31bf3856ad364e35" 
priority="1" group="0"/>
</soapExtensionTypes>
</webServices>

Listing 2

public class ServerProxy: Microsoft.BizTalk.WebServices.ServerProxy.ServerProxy
{
new protected object[] Invoke(string functionName, object[] parameters,
Type[] outParameters, int bodyPartIndex, ArrayList inHeaders,
ArrayList inOutHeaders, out ArrayList inOutHeaderResponses,
out ArrayList outHeaderResponses, Type[] outHeaderTypes,
string[] outHeaderNamespaces, SoapUnknownHeader[] unknownHeaders,
out SoapUnknownHeader[] unknownHeaderResponses,
bool oneWay, bool spsSsoEnabled, bool spsSsoRequired)
{
// Find the security token containing the
// security principal.
SecurityToken principalToken = FindPrincipalToken();
if (principalToken != null)
{
IPrincipal principal = 
principalToken.Principal;

// Convert the principal to a XML serializable form.
principal = ConvertPrincipalToSerializableForm(principal);

// Add the principal to the input SOAP
// headers collection.
if (inHeaders == null)
{
inHeaders = new ArrayList();
}
inHeaders.Add(principal);
}

// Invoke the BizTalk server proxy.
return base.Invoke(functionName, parameters,
outParameters,
bodyPartIndex, inHeaders, inOutHeaders,
out inOutHeaderResponses, out
outHeaderResponses, outHeaderTypes,
outHeaderNamespaces, unknownHeaders,
out unknownHeaderResponses, oneWay,
spsSsoEnabled,
spsSsoRequired);
}
}

Listing 3

public class SecurityContext
{
public static IPrincipal GetPrincipal(XLANGMessage message)
{
XmlPrincipal principal = null;

// Get the serialized XML from the message
// context.
string principalXml = (string)
message.GetPropertyValue(
typeof(SecureBizTalk.SecuritySchemas.XmlPrincipal));
if (principalXml != null)
{
// Deserialize.
XmlSerializer serializer = new
mlSerializer(typeof(XmlPrincipal));
StringReader reader = new 
StringReader(principalXml);
principal = (XmlPrincipal)
serializer.Deserialize(reader);
}
return principal;
}
}