Skip to main content
April 22, 2009
Answered

Error converting CFML arguments to Java classes for web service invocation.

  • April 22, 2009
  • 5 replies
  • 1523 views

Hello all.

I am working on writting a small application that will use a web service that is provided by our IVR (Angel.com). I am able to login, however when I attempt to do anything with complex objects, I get the error stated in the title.

It seems to be having a problem with the array, because when I remove it, or turn it into a simple string, i get errors about the function not being found. I am fairly new to web services, and especially dealing with complex data types, so any help would be much appreciated.

You can see my testing page at

http://webservices.fpitesters.com/AngelCalls.cfm

The WSDL I am using can be found at

http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl

Here is sample code that does what I want it to do in Java / Apache Axis

http://www.socialtext.net/ivrwiki/index.cgi?java_sample_code

Here is a description of the function I am having problems with

http://www.socialtext.net/ivrwiki/index.cgi?placecall

And attached is my code.

     <cfset email = "xxxxxxxxxxxxxxxxxx">
     <cfset pin = "xxxxxxxxxxxx">


     
     <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="login" returnvariable="login">
          <cfinvokeargument name="email" value="#email#"/>
          <cfinvokeargument name="pin" value="#pin#"/>
     </cfinvoke>

     <cfdump var="#login#">
     
     <cfset Token = login.getToken()>
     
     <cfdump var="#token#">
     
     <cfset CallItem.maxWaitTime = 100>
     <cfset CallItem.phoneNumbers[1] = "7632344306">
     <cfset CallItem.siteNumber = 100041>
     
     <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="placeCall" returnvariable="call">
          <cfinvokeargument name="Token" value="#Token#"/>
          <cfinvokeargument name="CallItem" value="#CallItem#"/>
     </cfinvoke>
     
     <cfdump var="#call#">

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer jmmorgan

If you are not initializing phoneNumbers as an array before setting

<cfset CallItem.phoneNumbers[1] = "7632344306">

it will be passed as a struct with a key of 1.  This could cause your argument conversion error.

So:

<cfset CallItem.maxWaitTime = 100>
<cfset CallItem.phoneNumbers[1] = "7632344306">
<cfset CallItem.siteNumber = 100041>

Will result in

struct
MAXWAITTIME100
PHONENUMBERS
struct
17632344306
SITENUMBER100041
<cfset CallItem = StructNew() > <!--- For Good Measure --->
<cfset CallItem.maxWaitTime = 100 >
<cfset CallItem.phoneNumbers = arrayNew(1) /> <!--- Required --->
<cfset CallItem.phoneNumbers[1] = "7632344306">
<cfset CallItem.siteNumber = 100041>

Will result in

struct
MAXWAITTIME100
PHONENUMBERS
array
17632344306
SITENUMBER100041

- Jason Morgan

5 replies

jmmorganCorrect answer
Participating Frequently
April 23, 2009

If you are not initializing phoneNumbers as an array before setting

<cfset CallItem.phoneNumbers[1] = "7632344306">

it will be passed as a struct with a key of 1.  This could cause your argument conversion error.

So:

<cfset CallItem.maxWaitTime = 100>
<cfset CallItem.phoneNumbers[1] = "7632344306">
<cfset CallItem.siteNumber = 100041>

Will result in

struct
MAXWAITTIME100
PHONENUMBERS
struct
17632344306
SITENUMBER100041
<cfset CallItem = StructNew() > <!--- For Good Measure --->
<cfset CallItem.maxWaitTime = 100 >
<cfset CallItem.phoneNumbers = arrayNew(1) /> <!--- Required --->
<cfset CallItem.phoneNumbers[1] = "7632344306">
<cfset CallItem.siteNumber = 100041>

Will result in

struct
MAXWAITTIME100
PHONENUMBERS
array
17632344306
SITENUMBER100041

- Jason Morgan

April 23, 2009

Thank you so much for your very helpful answer, that did the trick. It seems odd to me that the array is a struct unless otherwise declaired, but hey, live and learn. Again thank you, I really appreciate it.

April 23, 2009

Since we are on the subject, do you have any idea what this error means?

The getOutboundCallGUID method was not found.
Either there are no methods with the specified method name and argument types, or the getOutboundCallGUID method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that matched the provided arguments. If this is a Java object and you verified that the method exists, you may need to use the javacast function to reduce ambiguity.

The call that you helped me put together returns a method with that name (like how login returns a method called getToken() which i called with   

<cfset Token = login.getToken()> ) however, when I attempt to call it in the same fashion ex:

<cfset Guid = placecall.getOutboundCallGUID()>

I get the error above. Again, I'm sure this is probably simple stuff for you web service masters, I am just kinda breaking into it however, and some of these errors are fairly cryptic for a newbie like me. This is my full source now.

     <cfset email = "xxxxxxxxxxxxxxxxxx">
     <cfset pin = "xxxxxxxxx">


     
     <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="login" returnvariable="login">
          <cfinvokeargument name="email" value="#email#"/>
          <cfinvokeargument name="pin" value="#pin#"/>
     </cfinvoke>

     <cfdump var="#login#">
     
     <cfset Token = login.getToken()>
     
     <cfdump var="#token#">
     
     <cfset CallItem = StructNew() > <!--- For Good Measure --->
     <cfset CallItem.maxWaitTime = 100 >
     <cfset CallItem.phoneNumbers = arrayNew(1) /> <!--- Required --->
     <cfset CallItem.phoneNumbers[1] = "7632344306">
     <cfset CallItem.siteNumber = 100041>
     
     <cfinvoke webservice="http://www.angel.com/outbound/wsdl/OutboundCallService.wsdl" method="placeCall" returnvariable="placecall">
          <cfinvokeargument name="Token" value="#Token#"/>
          <cfinvokeargument name="CallItem" value="#CallItem#"/>
     </cfinvoke>
     
     <cfdump var="#placecall#">

        <!--- This is where the error occures now---->

     <cfset Guid = placecall.getOutboundCallGUID()>
     
     <cfdump var="#Guid#">