ColdFusion Webservices and 'non-required' parameters

So I had this CF web service for single sign-on authentication; it had one required parameter and everything was well with the world.

Then came the change request to add three new non-required parameters. Some of you are saying, "Oh, I know where THIS is going.". If so, then... WHY DIDN'T YOU TELL ME?!?! :-)

So I added these three new "non-required" parameters like a good little code monkey by setting them to required="false". Then I went off to test everything to make sure it was still functioning as expected. I totally expected no change at all in the test results; after all, I didn't really change any existing functionality right? But as much as I love to typo, I had to test it out.

I cleared the web service cache and loaded the app to test the web service but I was greeted with the generic "Web service operation "blahblah" with parameters {blahblah} could not be found". So I thought, maybe I have to be explicit with the parameter name now that there are three new non-required parameters. So I changed up the method call to define the parameter name but still... the same error (or close). "Web service operation "blahblah" with parameters {blah={blahblah}} could not be found".

After obsessing over whether or not something was cached wrong and finally determining that it was not, i decided that MAYBE if I add a default value to the non-required parameters, that would help... of course it did not.

So, feeling like a complete failure, off to The Google I went. after a few rounds of Pacman, I ran a search and came up with this little gem.

4. The attribute setting required="false" for the cfargument tag is ignored. 
ColdFusion considers all parameters as required.

WHAT?! Ugh!

You cannot, NOT specify a parameter, required or not, in a CF web service call, period. At least not from ColdFusion. I'm not sure if another language would be able to call the method and not specify the non-required parameter values though.

What I found most amusing about all of this was that after all these years of writing web services, today was the first time I tried to use a non required parameter; I've apparently always used them all! Waste not, want not right?

Another lesson learned.

Most Recent Photos