Add SOAP header in SOAP service
search cancel

Add SOAP header in SOAP service


Article ID: 236611


Updated On:


CA API Gateway


I am facing issue while adding the soap header elements in the backend SOAP service.

Here are my requirement.

1) I will get below request from the requester.

<soapenv:Envelope xmlns:soapenv="" xmlns:cus="" xmlns:data="">

2) But I have to add SOAP headers in the request while calling to backend like this 


      <SessionType xmlns="http://xxxxxx,com/webservices">Stateful</SessionType>

      <UsernameToken xmlns="">IF_SAP</UsernameToken>

      <PasswordText xmlns="">if_sap_T</PasswordText>



4) Issue is when we pass <soapenv:Header> </soapenv:Header> in the request my API works but there is limitation from requester side they can't send the empty header. hence I tried to add empty header and throwing below error.

20220303 18:44:52.818 WARNING   8803 Unable to insert element because the new element was not a well-formed XML fragment

How can we add this to the request .



Release :

Component :


To be able to add a header it needs to match the defined schema 

Use the following context variable value to add the Header to your soap request using the add-or-remove-xml-element-s-assertion

<soapenv:Header xmlns:soapenv="">
     <SessionType xmlns="">Stateful</SessionType>
     <UsernameToken xmlns="">IF_SAP</UsernameToken>
     <PasswordText xmlns="http://xxxxx. com/webservices">if_sap_T</PasswordText>