Copy link to clipboard
Copied
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#">
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 | |||||
---|---|---|---|---|---|
MAXWAITTIME | 100 | ||||
PHONENUMBERS |
| ||||
SITENUMBER | 100041 |
<cfset CallItem = StructNew() > <!--- For Good Measure --->
<cfset CallItem.maxWaitTime = 10
...
Copy link to clipboard
Copied
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 | |||||
---|---|---|---|---|---|
MAXWAITTIME | 100 | ||||
PHONENUMBERS |
| ||||
SITENUMBER | 100041 |
<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 | |||||
---|---|---|---|---|---|
MAXWAITTIME | 100 | ||||
PHONENUMBERS |
| ||||
SITENUMBER | 100041 |
- Jason Morgan
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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#">
Copy link to clipboard
Copied
Glad I could help.
The result of PlaceCall is an Array. So your code needs to be :
<cfset Guid = placecall[1].getOutboundCallGUID()>
This assumes you are only interested in the first element of course.
Copy link to clipboard
Copied
I hope this helps.
kenji776 wrote:
... It seems odd to me that the array is a struct unless otherwise declaired ...
CF does not know if you are referencing an array or a struct. It can refer to structures with the same notation as you would refer to an array. IE.
<cfset CallItem.maxWaitTime = 100 >
<cfset CallItem.phoneNumbers[1] = "7632344306" >
<cfset CallItem.siteNumber = 100041 >
is the same as
<cfset CallItem["maxWaitTime"] = 100 >
<cfset CallItem["phoneNumbers"][1] = "7632344306" >
<cfset CallItem["siteNumber"] = 100041 >
So there is know way for CF to know that you are referencing an array vs a structure. It could make a guess and say that since the index is numeric
create an array but that is not any more valid than the way it does it.