SOAP Request Parameter Order Can Make a Difference

I built a SOAP request that wasn't working. It took about an hour or so to discover that it wasn't working due to parameter order. It's best to put the parameters in the same order that's in the WSDL. What was also interesting was that the element names that I used in the SOAP request actually didn't make a difference. It was specifically checking the order.

A third party built the web service in Java but I'm not sure which SOAP engine they're using or how it was developed. In any case, it's just something to keep in mind if your call isn't working and it looks like it should!

Published September 17, 2005 · Updated September 14, 2006
Categorized as Other
Short URL: https://snook.ca/s/413

Conversation

4 Comments · RSS feed
Ben Kennedy said on September 17, 2005

Yeah, I had found the same awhile ago, when I started to build some stuff using the SOAP PHP back-end from PEAR and the WebServices API on Mac OS X Panther.

It was kind of confounding given that key/value and random ordering was supposed to be a benefit of SOAP over XML-RPC.

Justin Perkins said on September 19, 2005

Since the SOAP request is a method (function) call and you cannot simply change the order of paramters in a function call without getting unexpected results, changing the order of parameters in a SOAP call would likely cause unexpected results as well.

Sure, we get to specify paramter names with SOAP, unlike normal function calls, but still, sounds like you're just asking for trouble if you change the parameter order (not to mention that would cause confusion for other people looking at your code).

Jonathan Snook said on September 19, 2005

Well, a SOAP request is just XML so my thoughts are that it's the SOAP implementation that would determine how parameters should match up. In any case, I paid no attention to it. Now that I realize it's an issue, I'll make sure to keep 'em in line.

Justin Perkins said on September 19, 2005

> Well, a SOAP request is just XML so my thoughts are that it's the SOAP implementation that would determine how parameters should match up.

I absolutely agree, but that varies from vendor to vendor. Some vendors may grab SOAP parameter values by element name (the proper way) and others may grab the values by node position (what you're probably running into).

Like you said, stick to the format specified by the WSDL and nobody gets hurt.

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.