Discuss this help topic in SecureBlackbox Forum
SOAP: Add references to signature
To add references to the signature you need to use AddReference() method of a SOAP or WSS signature handler.
The sample below adds a reference to the Body element and set its Id attribute, if not set:
C#:
TElXMLWSSSignatureHandler Handler = new TElXMLWSSSignatureHandler(null);
...
// "body-id-1" is a custom id that should be added,
// if the body element doesn't have an id attribute
Handler.AddReference(SOAPMessage.Envelope.Body, "body-id-1");
Delphi:
Handler := TElXMLWSSSignatureHandler.Create(nil);
...
// "body-id-1" is a custom id that should be added,
// if the body element doesn't have an id attribute
Handler.AddReference(SOAPMessage.Envelope.Body, 'body-id-1');
The sample below adds a Timestamp to the first WS-Security header, then adds a reference to it:
C#:
TElXMLWSUTimestamp Timestamp = new TElXMLWSUTimestamp();
SOAPMessage.get_SecurityHeaders(0).AddToken(Timestamp);
Timestamp.CreatedUTC = DateTime.UtcNow;
Timestamp.ExpiresUTC = timestamp.CreatedUTC.AddMinutes(1);
Timestamp.ID = "timestamp-id-1";
Handler.AddReference(Timestamp);
Delphi:
Timestamp := TElXMLWSUTimestamp.Create();
SOAPMessage.SecurityHeaders[0].AddToken(Timestamp);
Timestamp.CreatedUTC := SBUtils.DateTimeUtcNow;
Timestamp.ExpiresUTC := DateTimeAddDays(Timestamp.CreatedUTC, 1);
Timestamp.ID := 'timestamp-id-1';
Handler.AddReference(Timestamp);