Integration Platform Technologies: Siebel Enterprise Application Integration > 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. You can also define the methods you want to call on the filter.

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 want to call, as well as the corresponding input and output parameters.

  function Service_PreInvokeMethod (MethodName, Inputs, Outputs) {

if(MethodName == "StripHeader") {

  if(Inputs.GetChildCount() > 0) {

  // Set the input SOAP message property set as the output.

  Outputs.InsertChildAt(Inputs.GetChild(0), 0);

  var soapEnv = Outputs.GetChild(0);

  if(soapEnv.GetChildCount() == 2) // headers and body {

// Here is where the header is found and processed.

var count = soapEnv.GetChildCount();

var i = 0;

var headerParam1;

var headerParam2;

var headerParam3;

// Use a loop just in case the header is not the first hierarchy.

for (; i < count; i++) {

  // For simplicity, the string comparison must be done using the exact same value
  // as the SOAP message tag name.

  if (soapEnv.GetChild(i).GetType() == "soapenv:Header") {

// Found the header. Now it is processed.

var soapHeader = soapEnv.GetChild(i);

// This example assumes that the following header hierarchy is received:

// <soapEnv:Header>

// <headerParam1>Value1</headerParam1>

// <headerParam2>Value2</headerParam2>

// <headerParam3>Value3</headerParam3>

// </soapEnv:Header>

// The parameters headerParam1, headerParam2, and headerParam3

// are saved into variables. Nothing further done with them.

headerParam1 = soapHeader.GetChild(0);

headerParam2 = soapHeader.GetChild(1);

headerParam3 = soapHeader.GetChild(2);

break; // Stop the loop after the header is found.

}

  }

  // Must remove the header from the SOAP property set.

  soapEnv.RemoveChild(i);

  }

}

  }

else if(MethodName == "AddHeader") {

  if(Inputs.GetChildCount() > 0) {

// Create the SOAP header hierarchy with the desired data.

var soapHeader = TheApplication().NewPropertySet();

soapHeader.SetType("soapEnv:Header");

soapHeader.SetProperty("xmlns:soapEnv",
"http://schemas.xmlsoap.org/soap/envelope/");

// These will be created as property sets because we want the following header:

// <soapEnv:Header>

// <headerParam1>Value1</headerParam1>

// <headerParam2>Value2</headerParam2>

// <headerParam3>Value3</headerParam3>

// </soapEnv:Header>

var param1PS = TheApplication().NewPropertySet();

var param2PS = TheApplication().NewPropertySet();

var param3PS = TheApplication().NewPropertySet();

param1PS.SetType("headerParam1");

param1PS.SetValue("Value1");

param2PS.SetType("headerParam2");

param2PS.SetValue("Value2");

param3PS.SetType("headerParam3");

param3PS.SetValue("Value3");

// Add the data to the SOAP header.

soapHeader.AddChild(param1PS);

soapHeader.AddChild(param2PS);

soapHeader.AddChild(param3PS);

// Get the SOAP envelope from the SOAP hierarchy.

var soapEnv = Inputs.GetChild(0);

// Add the header to the SOAP envelope.

soapEnv.InsertChildAt(soapHeader, 0);

Outputs.InsertChildAt(soapEnv, 0);

}

}

return(CancelOperation);

  }

Integration Platform Technologies: Siebel Enterprise Application Integration Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices.