Question
· Feb 16, 2022

Add header to SOAP request

Hello.

I'm trying add header to soap request.

header:

<soapenv:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secex...">
        <wsse:UsernameToken>
            <wsse:Username>TEST</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-p...">Test!123</wsse:Password>
        </wsse:UsernameToken>
    </wsse:Security>
</soapenv:Header>

I create class

Class WebService.Header Extends %SOAP.Header
{

Parameter ELEMENTQUALIFIED = 1;

Parameter XMLSEQUENCE = 1;

Property Security As pgw.WebService.Header.Security(XMLNAME = "Security");

}


Class WebService.Header.Security Extends (%RegisteredObject, %XML.Adaptor)
{ Parameter NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secex..."; Property UserNameToken As pgw.WebService.Header.Security.UsernameToken(XMLNAME = "UserNameToken"); }

Class WebService.Header.Security.UsernameToken Extends (%RegisteredObject, %XML.Adaptor)
{ Property UserName As %String(MAXLEN = "", XMLNAME = "UserName"); Property Password As %String(MAXLEN = "", XMLNAME = "Password"); }

set wsHeader = ##class(WebService.Header).%New()
set userName = ##class(WebService.Header.Security.UsernameToken).%New()

set userName.UserName="Test"
set userName.Password="test!test"

do webService.SetHttpHeader("Header",userName)

While sending SOAP request header is missing...

$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.2 (Build 867_4_20165U) Mon Aug 17 2020 11:28:28 EDT
Discussion (4)1
Log in or sign up to continue