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

Fix namespace and type for nil attribute #65

Closed philipc closed 10 years ago

philipc commented 10 years ago

This is my first time using soap, so this change may be wrong. I need to include a null value in the soap request. I had two issues. First, the 'nil' attribute wasn't being added at all. If I change the type of the 'true' from boolean to string then it is added. However, the server ignored the 'nil' attribute. To get it to work I had to qualify it with the xsi namespace.

I've added the xsi definition at the same location as the nil attribute. I did it this way because it matches the behaviour of the existing Silverlight client for this service.

An alternative way of fixing this would be to define the xsi namespace in the envelope, and there's a comment there about doing that. I can fix it that way if you prefer. If so, should this be a config option?

There's also some nil handling in the SOAPObject handler. Should the xsi namespace be specified there too? I see in the git history that it used to be, but that was removed in 2b68f65a63ce183beaa53a965b7a0bdc23f34267.

doedje commented 10 years ago

I read this on my phone... I'll have to do some reading on a computer to give you the answers on the questions you asked.... Give me some more hours :)

doedje commented 10 years ago

I did some reading: indeed the nil attribute should be a string true.

I was thinking about adding

  'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
  'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema'

to the soapEnvelope by default. Then it would make sence to add the xsi:nil attribute.

philipc commented 10 years ago

I've modified the commit to add xsi and xsd to the envelope.

doedje commented 10 years ago

Looks good, I'll merge and bump the version as soon as I am behind a 'normal' computer (as opposed to a phone)

doedje commented 10 years ago

Thanx a lot!