How to apply namespace qualifier on parent tag only

129 Views Asked by At

I have a soap request that needs to look like this, with the 'user:' qualifier ONLY pertaining to the 'getTopQuestions' tag. Here is what the request SHOULD look like:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body>
        <user:getTopQuestions>
            <interfaceId>4</interfaceId>
            <numberOfQuestions>10</numberOfQuestions>
        </user:getTopQuestions>
    </soap:Body>
</soap:Envelope>

However, my request looks like this. As you can see, the 'user:' namespace qualifier is attached to the children tags of the parent 'user:getTopQuestions'

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body>
        <user:getTopQuestions>
            <user:interfaceId>4</user:interfaceId>
            <user:numberOfQuestions>10</user:numberOfQuestions>
        </user:getTopQuestions>
    </soap:Body>
</soap:Envelope>

How do I get the 'user:' namespace qualifier off of the child tags 'interfaceId' and 'numberOfQuestions'?

Here is my request:

 $.soap({
          url,
          method: options.method,
          data: options.data || {},

          success: soapResponse => {
              let responseContent = `${options.method}Response`;
              let body = 'Body';
              let data = soapResponse.toJSON();
              if (data['soap:Body']) {
                  responseContent = `ns1:${responseContent}`;
                  body = `soap:${body}`;
              }
              data = data[body][responseContent];
              deferred.resolve(data);
          },
          error: SOAPResponse => {
              deferred.reject(SOAPResponse);
          },            
          namespaceQualifier: "user:",
          envAttributes: {
              'xmlns:user': '/com/intelliresponse/search/user'
          },
          SOAPAction: " "
      });
1

There are 1 best solutions below

0
Rakesh Dash On

Can you remove the ":" from the namespaceQualifier as suggested here https://github.com/zachofalltrades/jquery.soap use namespaceQualifier: 'myns', // used as namespace prefix for all instead of namespaceQualifier: ':myns' //with a colon