- Usage example of the SOAPAddXMLSignature function
Usage example of the SOAPAddXMLSignature function
This example is used to create an XML signature and to add it to a Webservice request.
Caution: This example does not operate via a copy/paste. Indeed, SOAPAddXMLSignature takes in 2nd parameter the location where the signature will be placed. This location is described in the WSDL that we want to use, by an XSD type.
In this code example, this location is described in "Security.Assetion.Signature" that comes from the WSDL of the Webservice that we want to call.
To adapt this code, we must refer to the WSDL used to find this location.
MyRequest is wsRequest
MySecurity is Security
// Builds an identifier
id is string = GetGUID(guidFormatted)
id = "_" + Middle(id, 2, Length(id) - 2)
// Initializes the signature
cMySignature is xmlSignature
cMySignature.AlgorithmNormalization = atC14NExclusive
cMySignature.AlgorithmSignature = asRSA_SHA_256
// Key file OR certificate retrieved by the certificate functions
cMySignature.Key = fExeDir + fSep + "mykey.p12"
cMySignature.KeyPassword = "password"
cMySignature.KeyFileType = tfcPKCS12
cMySignature.Reference.AlgorithmHash = HA_SHA_256
cMySignature.Reference.URI = "#" + id
cMySignature.Reference.Transformation = atEnveloped
cMySignature.Reference.Transformation = atC14NExclusive
x509 is xmlSignatureInformationKeyX509
x509..WithCertificate = True
cMySignature.KeyInformation = x509
// End of signature initialization
dtCurrentDateTime is DateTime
MySecurity.Assertion:ID = id
MySecurity.Assertion:IssueInstant = dtCurrentDateTime
MySecurity.Assertion:Version = "2.0"
MySecurity.Assertion.Issuer = "test"
MaSecurity.Assertion.Issuer:Format = ...
// Adds the signature
SOAPAddXMLSignature(MaRequest, MySecurity.Assertion.Signature, cMySignature)
This page is also available for…