Unofficial Content

Under certain circumstances, when consuming a Webservice using SOAP protocol, it might be necessary to include SOAP Headers.

There are two ways of doing it, by creating an SDT with the parameters or by embedding a raw text into the headers (if you specify both, only SoapHeaders is considered).

Including an SDT in SoapHeaders

First define an SDT with the data to be included, in this example having Username and Password, and then use a non standard function to add the SDT into the headers.

&sdtHeader.Username = "User" 
&sdtHeader.Password = "pass" 
&ws.SoapHeaders.Add(&sdtHeader) // &ws is a variable based on the web service created data type. 

You need to set the property "Standard Functions" value "Allow non-standard functions" in order to avoid specification errors.

SAC 19459

Embedding your own defined text string into soapHeadersRaw

Define the SOAP text into a character variable, and then add it to the SOAP headers using a non standard function.

&soapHeadersRaw = '<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">'+\
'     <u:Timestamp u:Id="_0">'+\
'        <u:Created>2017-02-24T16:17:00.723Z</u:Created>'+\
'        <u:Expires>2017-02-24T16:22:00.723Z</u:Expires>'+\
'     </u:Timestamp>'+\
'     <o:UsernameToken u:Id="uuid-44e98461f-80b9-482c-a902-8b961406a43a-1">'+\
'        <o:Username>user</o:Username>'+\
'        <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">pass</o:Password>'+\
'     </o:UsernameToken>'+\
'  </o:Security>'
 
&ws.soapHeadersRaw = &soapHeadersRaw   // &ws is a variable based on the web service created data type. 

You need to set the property "Standard Functions" value "Allow non-standard functions" in order to avoid specification errors.

SAC 34995

 

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant