doedje / jquery.soap

This script uses $.ajax to send a SOAP:Envelope. It can take XML DOM, XML string or JSON as input and the response can be returned as either XML DOM, XML string or JSON too.
352 stars 147 forks source link

Option envAttributes not working as expected #54

Closed Cultti closed 10 years ago

Cultti commented 10 years ago

Hi,

I'm trying to create the following SOAP request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:whm="http://namespace.org/WHM">
   <soap:Body>
      <test>Test</test>
   </soap:Body>
</soap:Envelope>

But I'm ended up with:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <test>Test</test>
   </soap:Body>
</soap:Envelope>

Code what I'm using:

var xml = '<test>Test</test>';

$.soap({
   url: "https://example.com/ws/Service.asmx",
   envAttributes: {
      'xmlns:whm': 'http://namespace.org/WHM'
   },
   data: xml,
   success: function(resp) {
      console.log("RESPONSE OK");
   },
   error: function(resp) {
      console.log("RESPONSE FAILED");
   }
});

I'm using jQuery v1.9.1 and jQuery Soap v1.3.9

Please assist if possible.

Thank you

doedje commented 10 years ago

Hi Timo,

Quick reply from my iphone: try this please:

envAttributes: { 'whm': 'http://namespace.org/WHM' }, I think that should work but was not able to test it on my iPhone....

please let me know!

greetinx

REMY

On 11 Jul 2014, at 14:59, Timo Salola notifications@github.com wrote:

Hi,

I'm trying to create the following SOAP request:

soap:Body Test /soap:Body /soap:Envelope But I'm ended up with: soap:Body Test /soap:Body /soap:Envelope Code what I'm using: var xml = 'Test'; $.soap({ url: "https://example.com/ws/Service.asmx", envAttributes: { 'xmlns:whm': 'http://namespace.org/WHM' }, data: xml, success: function(resp) { console.log("RESPONSE OK"); }, error: function(resp) { console.log("RESPONSE FAILED"); } }); I'm using jQuery v1.9.1 and jQuery Soap v1.3.9 Please assist if possible. Thank you — Reply to this email directly or view it on GitHub.
todd-lockhart commented 10 years ago

Might be IE8 modifications causing issues, too. Testing now.

Yup... hang tight.

todd-lockhart commented 10 years ago

Change line 80 in jquery.soap.js from - for (var i = 0; i < config.envAttributes.length; i++) {

to for (var i in config.envAttributes) {

Need to go back and make sure no other loops are causing different issues.

todd-lockhart commented 10 years ago

That seems to be the only instance of overzealous loop conversion... sorry.

Cultti commented 10 years ago
envAttributes: {
   'whm': 'http://namespace.org/WHM'
},

This did not work.

Replacing line 80 with

for (var i in config.envAttributes) {

did work as Todd suggested. Thank you!