Create a webservice to accept an array of structures/components

2007-10-26 Thread Etwan Sherdloo
Goal: To create a webservice that can accept an array of structures/components.

Problem: The webservice will not accept the array of structures/components 
passed to it.

Code:
1) The following is the code that creates the array of structures/components 
and invokes the webservice. (Testws.cfm)

cfoutput

!--- Creat Test Game Object ---
cfset arrGame = ArrayNew(1)
cfloop index=i from=1 to=5
cfset arrGame[i] = CreateObject(component, gameTest)
cfset arrGame[i].setGameID(ToString(i))
cfset arrGame[i].setHomeSSID(OHSSTEST  i)
/cfloop
barrGame:/bbrcfdump var=#arrGame#
cfinvoke 
webservice=http://dev.schedulestar.com/Tim/webservicetest.cfc?wsdl; 
method=complextype1 returnvariable=serviceResult Games=#arrGame#

brbrbserviceResult:/bbrcfdump var=#serviceResult#
/cfoutput

2) The following is the code for the web service (webservicetest.cfc)

cfcomponent
cffunction name=complextype1 returntype=gameTest[] access=remote
cfargument name=Games type=gameTest[] required=yes


cfset arrGame = arraynew(1) !--- Return Variable ---

!--- Creat Game ---
cfloop index=s from=1 to=#arraylen(Games)#
cfset arrGame[s] = CreateObject(component, 
gameTest)
cfset arrGame[s].setGameID(ToString(s))
cfset arrGame[s].setHomeSSID(Games[s].getHomeSSID)
/cfloop

cfreturn arrGame
/cffunction

/cfcomponent

3) The following is the component. An array of this component is made and 
passed to the webservice. (gameTest.cfc)

cfcomponent
cfproperty name=GameID type=string
cfproperty name=HomeSSID type=string

!--- Initialize ---
cfscript
this.GameID = 0;
this.HomeSSID = ;
/cfscript

!--- Methods ---
cffunction name=getGameID access=public returntype=string
cfreturn this.GameID
/cffunction
cffunction name=setGameID access=public
cfargument name=game type=string required=yes
cfset this.GameID = game
/cffunction

cffunction name=getHomeSSID access=public returntype=string
cfreturn this.HomeSSID
/cffunction
cffunction name=setHomeSSID access=public
cfargument name=ssid type=string required=yes
cfset this.HomeSSID = ssid
/cffunction
/cfcomponent


Basically, the testWS.cfm file creates an array of the component and passes it 
to the webservice. No matter what I try to do, errors continue to be thrown. I 
believe the problem is in the code for the webservice. Thank you for your help. 

~|
Get the answers you are looking for on the ColdFusion Labs
Forum direct from active programmers and developers.
http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72catid=648

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292142
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Create a webservice to accept an array of structures/components

2007-10-26 Thread Dean Lawrence
Hi Etwan,

I think your problem is that gameTest[] is not a valid data type. It
is the name of an array, but it is not a datatype. The datatype would
simply be an array. This array holds multiple instances of the
gameTest object, but still the datatype itself would simply be an
array.

Dean

On 10/26/07, Etwan Sherdloo [EMAIL PROTECTED] wrote:
 Goal: To create a webservice that can accept an array of 
 structures/components.

 Problem: The webservice will not accept the array of structures/components 
 passed to it.

 Code:
 1) The following is the code that creates the array of structures/components 
 and invokes the webservice. (Testws.cfm)

 cfoutput

!--- Creat Test Game Object ---
cfset arrGame = ArrayNew(1)
cfloop index=i from=1 to=5
cfset arrGame[i] = CreateObject(component, gameTest)
cfset arrGame[i].setGameID(ToString(i))
cfset arrGame[i].setHomeSSID(OHSSTEST  i)
/cfloop
barrGame:/bbrcfdump var=#arrGame#
cfinvoke 
 webservice=http://dev.schedulestar.com/Tim/webservicetest.cfc?wsdl; 
 method=complextype1 returnvariable=serviceResult Games=#arrGame#

brbrbserviceResult:/bbrcfdump var=#serviceResult#
 /cfoutput

 2) The following is the code for the web service (webservicetest.cfc)

 cfcomponent
cffunction name=complextype1 returntype=gameTest[] 
 access=remote
cfargument name=Games type=gameTest[] required=yes


cfset arrGame = arraynew(1) !--- Return Variable ---

!--- Creat Game ---
cfloop index=s from=1 to=#arraylen(Games)#
cfset arrGame[s] = CreateObject(component, 
 gameTest)
cfset arrGame[s].setGameID(ToString(s))
cfset arrGame[s].setHomeSSID(Games[s].getHomeSSID)
/cfloop

cfreturn arrGame
/cffunction

 /cfcomponent

 3) The following is the component. An array of this component is made and 
 passed to the webservice. (gameTest.cfc)

 cfcomponent
cfproperty name=GameID type=string
cfproperty name=HomeSSID type=string

!--- Initialize ---
cfscript
this.GameID = 0;
this.HomeSSID = ;
/cfscript

!--- Methods ---
cffunction name=getGameID access=public returntype=string
cfreturn this.GameID
/cffunction
cffunction name=setGameID access=public
cfargument name=game type=string required=yes
cfset this.GameID = game
/cffunction

cffunction name=getHomeSSID access=public returntype=string
cfreturn this.HomeSSID
/cffunction
cffunction name=setHomeSSID access=public
cfargument name=ssid type=string required=yes
cfset this.HomeSSID = ssid
/cffunction
 /cfcomponent


 Basically, the testWS.cfm file creates an array of the component and passes 
 it to the webservice. No matter what I try to do, errors continue to be 
 thrown. I believe the problem is in the code for the webservice. Thank you 
 for your help.

 

~|
ColdFusion 8 - Build next generation apps
today, with easy PDF and Ajax features - download now
http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:292178
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4