Lets say we need to call directly from groovy a SOAP WS that requires authentication details to be sent in the Header.
For this example lets take a ICS WS, as ICS web services require this heather to be sent in the payload.
WSDL used will be : https://.oraclecloud.com/ic/ws/integration/v1/flows/osc/OSCTORESPONSYS_RENFE/1.0/?wsdl
This Ws has a method called process and the XML payload looks like so:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/crmCommon/content/outboundMessage/types/" xmlns:cus="http://xmlns.oracle.com/apps/custom">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>USER_NAME</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<typ:process>
<typ:OBJECT>
<cus:ATTRIBUTE>67323741</cus:ATTRIBUTE>
</typ:OBJECT>
</typ:process>
</soapenv:Body>
</soapenv:Envelope>
To call this Ws from groovy first step is to register the WS in Sales Cloud
You will register the WS normally as any SOAP WS , but you will use authentication none or basic in security schema, it will make no difference, as as we send the authentication in the call , in the payload.
I will use as reference name for the WS: ICS_WS
Now the groovy code we create the heather:
def soapHeader = '<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">'+
'<wsse:UsernameToken>'+
'<wsse:Username>USERNAME</wsse:Username>'+
'<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password>'+
'</wsse:UsernameToken>'+
'</wsse:Security>';
Next we create the payload for the operation:
def payload =
[[
'ATTRIBUTE' :<Value>
]]
Now we put all together and call the WS
def wsdc = adf.webServices.ICS_WS;
wsdc.requestSoapHeader =soapHeader ;
def response = wsdc.process(Ticket_Renfe);
Hope this will help with this type of web services.