Discuss this help topic in SecureBlackbox Forum
SOAP: Add SOAP signature to SOAP message
To add SOAP signature according to the SOAP-DSIG standard you would need to create an instance of TElXMLSOAPSignatureHandler component, add it to the SOAP message using TElXMLSOAPMessage.AddSignature() method, then add the references and setup other options, and finally call the TElXMLSOAPSignatureHandler.Sign() method to sign the message.
C#:
void SignSOAP(TElXMLSOAPMessage SOAPMessage, TElX509Certificate Certificate)
{
int HandlerIndex;
TElXMLSOAPSignatureHandler Handler = new TElXMLSOAPSignatureHandler(null);
HandlerIndex = SOAPMessage.AddSignature(Handler, true);
try
{
Handler.AddReference(SOAPMessage.Envelope.Body, true);
Handler.Sign(Certificate);
}
catch
{
SOAPMessage.RemoveSignature(HandlerIndex);
throw;
}
}
Delphi:
procedure SignSOAP(SOAPMessage : TElXMLSOAPMessage; Certificate : TElX509Certificate);
var
Handler : TElXMLSOAPSignatureHandler;
HandlerIndex : Integer;
begin
Handler := TElXMLSOAPSignatureHandler.Create(nil);
HandlerIndex := SOAPMessage.AddSignature(Handler, true);
try
Handler.AddReference(SOAPMessage.Envelope.Body, true);
Handler.Sign(Certificate);
except
SOAPMessage.RemoveSignature(HandlerIndex);
raise;
end;
end;