Discuss this help topic in SecureBlackbox Forum

SOAP: Set and get ID, MustUnderstand, EncodingStyle attributes

To set ID, MustUnderstand and EncodingStyle attributes, use the corresponding properties of the header or body element. The sample code below sets MustUnderstand and EncodingStyle attributes for WS-Security header:

C#:


if (SOAPMessage.SecurityHeaderCount > 0)
{
	SOAPMessage.get_SecurityHeaders(0).HeaderBlock.MustUnderstand = "1";
	SOAPMessage.get_SecurityHeaders(0).HeaderBlock.EncodingStyle = "http://www.w3.org/2003/05/soap-encoding";
}

Delphi:

if SOAPMessage.SecurityHeaderCount > 0 then
begin
  SOAPMessage.SecurityHeaders[0].HeaderBlock.MustUnderstand := '1';
  SOAPMessage.SecurityHeaders[0].HeaderBlock.EncodingStyle := 'http://www.w3.org/2003/05/soap-encoding';
end;

EncodingStyle for the body is set as shown in the code below:

C#:


if (SOAPMessage.Envelope.Body.EntryCount > 0)
{
	SOAPMessage.Envelope.Body.get_Entries(0).EncodingStyle = "http://www.w3.org/2003/05/soap-encoding";
}

Delphi:

if SOAPMessage.Envelope.Body.EntryCount > 0 then
  SOAPMessage.Envelope.Body.Entries[0].EncodingStyle := 'http://www.w3.org/2003/05/soap-encoding';

The Username token is added and its ID are set as follows:

C#:


TElXMLWSSEUsernameToken UsernameToken = new TElXMLWSSEUsernameToken();
SOAPMessage.get_SecurityHeaders(0).AddToken(UsernameToken);
UsernameToken.ID = "token-id";

Delphi:

UsernameToken := TElXMLWSSEUsernameToken.Create();
SOAPMessage.SecurityHeaders[0].AddToken(UsernameToken);
UsernameToken.ID := 'token-id';

To set and get "SOAP-SEC:id" attribute you can use the helper functions in SBXMLSOAPCore unit/namespace:

C#:


SBXMLSOAPCore.Unit.SOAPSecSetElementId(SOAPMessage.Envelope.Body.XMLElement, "body-id");

Delphi:

SBXMLSOAPCore.SOAPSecSetElementId(SOAPMessage.Envelope.Body.XMLElement, 'body-id');

To set and get "wsu:id" attribute you can use the helper functions in SBXMLWSSCore unit/namespace:

C#:


SBXMLWSSCore.Unit.WSUSetElementId(SOAPMessage.Envelope.Body.XMLElement, "body-id");

Delphi:

SBXMLWSSCore.WSUSetElementId(SOAPMessage.Envelope.Body.XMLElement, 'body-id');

How To articles about SOAP messages

Discuss this help topic in SecureBlackbox Forum