strong-soap icon indicating copy to clipboard operation
strong-soap copied to clipboard

Header does not use required prefix

Open saristar opened this issue 4 years ago • 2 comments

I'm trying to add header using client.addSoapHeader() method. The problem with the method is it is not using the required prefix in the xml output.

This is how I'm building the header.

const soaH = {
  "SOAHeader": {
        "Responsibility": "MANAGER",
        "RespApplication": "AR",
        "SecurityGroup": "STANDARD",
        "NLSLanguage": "AMERICAN",
        "Org_Id": "1"
    }
}
const qname = new QName('{http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/}oe:SOAHeader')
client.addSoapHeader(soaH, qname)

I want the header to generate with oe prefix

This is how it is built from strong-soap

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
utility-1.0.xsd">
      <wsse:UsernameToken>
        <wsse:Username>*********</wsse:Username>
        <wsse:Password>*********</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
    <ns1:SOAHeader xmlns:ns1="http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/">
      <SOAHeader>
        <Responsibility>MANAGER</Responsibility>
        <RespApplication>AR</RespApplication>
        <SecurityGroup>STANDARD</SecurityGroup>
        <NLSLanguage>AMERICAN</NLSLanguage>
        <Org_Id>1</Org_Id>
      </SOAHeader>
    </ns1:SOAHeader>
  </soap:Header>
  <soap:Body>
    <ns1:InputParameters xmlns:ns1="http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/get_order/">
      <ns1:P_API_VERSION_NUMBER>1.0</ns1:P_API_VERSION_NUMBER>
      <ns1:P_ORDER_NUMBER>5112</ns1:P_ORDER_NUMBER>
    </ns1:InputParameters>
  </soap:Body>
</soap:Envelope>

Expected Output:

<soapenv:Envelope xmlns:get="http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/get_order/" xmlns:oe="http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header>
      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
         <wsse:UsernameToken>
            <wsse:Username>*********</wsse:Username>
            <wsse:Password>*********</wsse:Password>
            <wsu:Created>2020-10-06T05:51:58.527Z</wsu:Created>
         </wsse:UsernameToken>
      </wsse:Security>
      <oe:SOAHeader xmlns:oe= "http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/">
        <oe:Responsibility>MANAGER</oe:Responsibility>
        <oe:RespApplication>AR</oe:RespApplication>
        <oe:SecurityGroup>STANDARD</oe:SecurityGroup>
        <oe:NLSLanguage>AMERICAN</oe:NLSLanguage>
        <oe:Org_Id>1</oe:Org_Id>
       </oe:SOAHeader>
   </soapenv:Header>
   <soapenv:Body>
      <get:InputParameters>
         <!--Optional:-->
         <get:P_API_VERSION_NUMBER>1.0</get:P_API_VERSION_NUMBER>
         <!--Optional:-->
         <get:P_ORDER_NUMBER>5005</get:P_ORDER_NUMBER>
      </get:InputParameters>
   </soapenv:Body>
</soapenv:Envelope>

I want the header to be built this way.

<oe:SOAHeader xmlns:oe= "http://xmlns.oracle.com/apps/ont/soaprovider/plsql/oe_inbound_int/">
  <oe:Responsibility>MANAGER</oe:Responsibility>
  <oe:RespApplication>AR</oe:RespApplication>
  <oe:SecurityGroup>STANDARD</oe:SecurityGroup>
  <oe:NLSLanguage>AMERICAN</oe:NLSLanguage>
  <oe:Org_Id>1</oe:Org_Id>
</oe:SOAHeader>

saristar avatar Jul 14 '21 05:07 saristar

  • 1

ikallali avatar Sep 14 '21 20:09 ikallali

If I may join this party late, @saristar does your WSDL define your header?

I can see the module has a unit test ('should add soap headers' in client-test.js) just for this case, and it passes -- unless I change qname and/or the header's name, in which case the output header element lacks the given qname. You can also see this header defined in the WSDL imported by the unit test, and the unit test's comments indicate it wants the "header schema defined in default-namespace.wsdl".

Therefore I ask whether your WSDL defines the header you want; seems like the output doesn't respect otherwise.

For now I worked around it by passing the header as string literal XML. As you saw, you can also still the header as object, but you lose the qname.

I'm not sure what it('should add soap headers with a namespace') is for, since it doesn't seem to test for a namespace in the header.

zbrook avatar Feb 16 '22 16:02 zbrook