Skip to main content
Participant
October 8, 2007
Answered

Help:using customered data type parameters for webservices

  • October 8, 2007
  • 2 replies
  • 400 views
file answer.cfc
<cfcomponent>
<cfproperty name="person" type="name">
<cfproperty name="answerText" type="string">
</cfcomponent>

file name.cfc
<cfcomponent>
<cfproperty name="Firstname" type="string">
<cfproperty name="Lastname" type="string">
</cfcomponent

webServices file myWebServices.cfc
<cfcomponent>
<cffunction name="echoAnswer" returnType="string" access="remote" output="false">
<cfargument name="input" type="answer">
<cfset returnS="">
<cfif arguments.input.person.FirstName eq "Xinkun">
<cfset returnS="Xinkun answered : ">
<cfset returnS=returnS&arguments.input.answerText>
<cfelse>
<cfset returnS="Xinkun did not answered">
</cfif>
<cfreturn returnS>
</cffunction>
</cfcomponent>

webServices client file servicesClientTest.cfm
<cftry>
<!---<cfobject component="answer" name="respons"> --->
<cfset respons=structNew()>

<!--- <cfobject component="name" name="tempN"> --->
<cfset tempN=StructNew()>
<cfset tempN.Firstname="Xinkun">
<cfset tempN.Lastname="Yuan">

<cfset respons.person=tempN>
<cfset respons.answerText="test answer">

<cfinvoke webservice=" http://localhost/CF_Webservices/myWebServices.cfc?wsdl" method="echoAnswer" returnvariable="outputV">
<cfinvokeargument name="input" value="#respons#">
</cfinvoke>
<cfoutput>
#outputV#
</cfoutput>
<cfcatch>
<cfoutput>
#cfcatch.Message#
</cfoutput>
</cfcatch>
</cftry>

There will be an error: 'Could not perform web service invocation "echoAnswer"' when I test the servicesClientTest.cfm.
help me please!
This topic has been closed for replies.
Correct answer jmmorgan
Are you using Application.cfc?

@Dan
The return type should not matter for this error. The error is occurring when the wsdl is generated. Return types are checked at runtime when the method is invoked and since you can have custom return types no compilation errors will occur.

I recreated the files exactly as you specified and it works just file when I remove my application.cfc.

See this entry http://corfield.org/blog/index.cfm/do/blog.entry/entry/Applicationcfc__onRequest_and_CFCs.


2 replies

jmmorganCorrect answer
Participating Frequently
October 8, 2007
Are you using Application.cfc?

@Dan
The return type should not matter for this error. The error is occurring when the wsdl is generated. Return types are checked at runtime when the method is invoked and since you can have custom return types no compilation errors will occur.

I recreated the files exactly as you specified and it works just file when I remove my application.cfc.

See this entry http://corfield.org/blog/index.cfm/do/blog.entry/entry/Applicationcfc__onRequest_and_CFCs.


Inspiring
October 8, 2007
I don't think that answer is one of the available types for a cfargument tag. The cfml reference manual will tell you what the acceptable types are. If you don't have one, the internet does.