2

When you are calling a method of a webservice and want to omit an unrequired numeric variable that has a default value set coldfusion will throw the following error:

The fault returned when invoking the web service operation is:<br>
<pre>'' java.lang.IllegalArgumentException</pre>

Example:

<cfinvoke
    webservice = "http://*.cfc?WSDL" 
    method="getFriendlyDay" 
    returnvariable="response"
    refreshWSDL="true"
>
        <cfinvokeargument name="dayNumber" omit="true"/>
</cfinvoke>

webservice component:

<cffunction name="getFriendlyDay" access="remote" returntype="any" output="no" description="get a friendly date from a number">   

        <cfargument name="dayNumber" type="numeric" required="no" default="0">
        ...
</cffunction>
Rumpleteaser
  • 4,142
  • 6
  • 39
  • 52

1 Answers1

2

My solution to this is to just not omit the argument. Pass in the default value. I just wanted to record this in case someone else gets the same error. Thus far it has only occurred on numeric values.

<cfinvoke
    webservice = "http://*.cfc?WSDL" 
    method="getFriendlyDay" 
    returnvariable="response"
    refreshWSDL="true"
>
        <cfinvokeargument name="dayNumber" value="0" >
</cfinvoke>

Update:

I believe this probably relates to the bug outlined here:

The way Coldfusion handles optional arguments as a remote service is that it allows the calling client to pass in a null value. In a document/literal or rpc/encoded WSDL description, an element can accept null unless it specifies "nillable='false'". The generated WSDLs from Coldfusion do not use "nillable='false'" or "minOccurs='0'" which instructs the client that they must include the parameter and that it is ok to pass in a null value.

The problem however is that "numeric" or "boolean" argument types that are optional will throw an "Illegal Argument Exception" when being called by a client who is trying to explicitly pass in null ...

Leigh
  • 28,765
  • 10
  • 55
  • 103
Rumpleteaser
  • 4,142
  • 6
  • 39
  • 52
  • Out of curiosity, what happens when you specify both ie ``? Reason for asking is [the docs](http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7e09.html) say *It is an error to specify omit="yes" if the cfinvokewebservice attribute is not specified.* I am hoping the actual behavior is not as silly as it sounds ... – Leigh Feb 21 '14 at 12:39
  • I tried both ways :) I assumed that cfinvokewebservice attribute referred to the name. – Rumpleteaser Feb 24 '14 at 02:06
  • Yep, sounds like that is the issue. (I agree with the author. Requiring that you specify an *optional* attribute really is counter intuitive...) – Leigh Feb 25 '14 at 14:44