JQuery SOAP can be called without prefix in elements, but prefixed in method

I need to make a SOAP call like this:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sig="http://anotherNameSpace">
   <soap:Body>
      <a:getCertificate xmlns:a="http://anotherNameSpace">
         <name>John</name>
      </a:getCertificate>
   </soap:Body>
</soap:Envelope>

      

So I wrote this javascript code using the jQuery SOAP plugin:

function soapCall(user, pass){
            $.soap({
                url: "myWdslAddress",
                method: "getCertificate",
                data: {
                    name: user
                },
                namespaceQualifier: "tns",
                namespaceURL: "http://anotherNameSpace",
                noPrefix: true,
                enableLogging: true,
                envAttributes: {
                    'xmlns:sig': 'http://anotherNameSpace'
                },
                HTTPHeaders: {
                    'Authorization': 'Basic ' + btoa(user + ':' + pass)
                }
            });
        }

      

But it doesn't work because it generates the following request:

<?xml version="1.0" encoding="UTF-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sig="http://anotherNameSpace">
   <soap:Body>
       <tns:getCertificate xmlns:tns="http://anotherNameSpace">
          <tns:name>John</tns:name>
      </tns:getCertificate>
    </soap:Body>
</soap:Envelope>

      

So I need to remove the "tns" prefix from the "name" element. I tried to remove the "namespaceQualifier:" tns "but it removes both from the getCertificate node and from the name node. I only need to remove the prefix from the" name "node; the getCertificate node must be prefixed.

Can this be done?

early

+3


source to share


1 answer


I found the following workaround to add the namespace to the method only, not to its elements. This is my soap request:

$.soap({ /
    url: 'http://webservice',
    method: 'method'
    appendMethodToURL: false,
    data: { mydata },

    namespaceQualifier: 'tns',
    namespaceURL: 'urn:my.namespace',
    noPrefix: true,
    elementName: 'tns:method',

    ...
});

      



The important part is to set up noPrefix: true

and add a namespace hardcoded to elementName

that is the same as the method.

+1


source







All Articles