Silly mistakes in web service implementation

Came across a strange problem this week using a web service from 3rd party. It’s a soap based web service. When we pass the XML with the required data elements in certain order, it works. If we did not follow that order, it complains invalid parameter or something. I guess in the code they have something like this:

if parameter_1 is invalid
return bad_parameter

if parameter_2 is invalid
return bad_parameter

In my opinion, we can do a simple fix as shown below:

if (parameter_1 is invalid) || (parameter_2 is invalid) || …

To be fair, I have made this kind of mistake myself, probably a while ago 🙂 I think it’s important for experienced developers have empathy towards people who make those mistakes, and understand how they come to the imperfect solution, and how to avoid those problems in the future.

(Update 05-09-2015) It looks like a common problem in web service, as explained in this thread. Quote:…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)…

Another post on stackoverflow about similar problem on WCF SOAP web service.