ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Rich Text Area control
  • Usage example of the SOAPAddXMLSignature function
SOAPAddXMLSignature (Example)
Usage example of the SOAPAddXMLSignature function
This example is used to create an XML signature and to add it to a web service request.
Caution: This example does not work 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 web service 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[1].AlgorithmHash = HA_SHA_256
cMySignature.Reference[1].URI = "#" + id
cMySignature.Reference[1].Transformation[1] = atEnveloped
cMySignature.Reference[1].Transformation[2] = atC14NExclusive
x509 is xmlSignatureInformationKeyX509
x509..WithCertificate = True
cMySignature.KeyInformation[1] = 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 = ...
"urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName"
 
 
// Adds the signature
SOAPAddXMLSignature(MaRequest, MySecurity.Assertion.Signature, cMySignature)
Minimum version required
  • Version 18
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/16/2024

Send a report | Local help