Integration Platform Technologies: Siebel eBusiness Application Integration Volume ll > Web Services > About Custom SOAP Filters >
Enabling SOAP Header Processing Through Filters
For each operation, you can set the inbound and outbound filters to be run. The methods to be invoked on the filter can also be defined. The following code sample illustrates a filter that has been written for the handling of custom SOAP headers. The interface provided by this code sample lets you define the method on the filter that you would like to invoke and also the corresponding input and output parameters. function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
if(MethodName == "StripHeader")
{
if(Inputs.GetChildCount() > 0)
{
Outputs.InsertChildAt(Inputs.GetChild(0), 0);
var soapEnv = Outputs.GetChild(0);
if(soapEnv.GetChildCount() == 2) // headers and body
{
var callBackHeader = soapHeader.GetChild(0);
if(callBackHeader.GetChildCount() == 2)
{
var headerContext = TheApplication().NewPropertySet();
headerContext.SetType("HeaderContext");
// get the header child property set
var callBackLocnHeader = callBackHeader.GetChild(0);
var correlationIdHeader = callBackHeader.GetChild(1);
headerContext.AddChild(callBackLocnHeader);
headerContext.AddChild(correlationIdHeader);
soapHeader.RemoveChild(0);
Outputs.AddChild(headerContext);
}
}
}
}
else if(MethodName == "AddHeader")
{
if(Inputs.GetChildCount() > 0)
{
Outputs.InsertChildAt(Inputs.GetChild(0), 0);
var soapEnv = Outputs.GetChild(0);
var soapHeader = TheApplication().NewPropertySet();
soapHeader.SetType("soapEnv:Header");
soapHeader.SetProperty("xmlns:soapEnv", "http://schemas.xmlsoap.org/soap/envelope/");
var correlationIdHeader = TheApplication().NewPropertySet();
correlationIdHeader.SetType("CorrelationId");
if(Inputs.GetChildCount() == 2)
{
// get the correlation id from soap header context
var soapHeaderCntxt = Inputs.GetChild(1);
var corIdHeader = soapHeaderCntxt.GetChild(0);
correlationIdHeader.SetValue(corIdHeader.GetValue());
}
else
{
// set default correlation id header
correlationIdHeader.SetValue("30");
}
soapHeader.AddChild(correlationIdHeader);
soapEnv.InsertChildAt(soapHeader, 0);|
}
}
else if(MethodName == "AddPSHeader")
{
if(Inputs.GetChildCount() > 0)
{
Outputs.InsertChildAt(Inputs.GetChild(0), 0);
var soapEnv = Outputs.GetChild(0);
var soapHeader = TheApplication().NewPropertySet();
soapHeader.SetType("PropertySetHeader");
soapHeader.SetProperty("xmlns:PropertySet", "http://www.siebel.com/propertyset");
var correlationIdHeader = TheApplication().NewPropertySet();
correlationIdHeader.SetType("CorrelationId");
if(Inputs.GetChildCount() == 2)
{
// get the correlation id from soap header context
var corIdHeader = soapHeaderCntxt.GetChild(0);
correlationIdHeader.SetValue(corIdHeader.GetValue());
}
else
{
// set default correlation id header
correlationIdHeader.SetValue("30");
}
soapHeader.AddChild(correlationIdHeader);
soapEnv.InsertChildAt(soapHeader, 0);
}
}
return (CancelOperation);
}
|