Discussion:
how to call this webservice
(too old to reply)
shafiur
2009-03-19 22:15:24 UTC
Permalink
How do I call this webservice?
I am trying to call using this code but it displays an error:?
Please help me.....




ACtual webservice
<cffunction name="getWebProfileHTML" access="remote" output="false"
returntype="string" displayname="getWebProfileHTML">
<cfargument name="passedStruct" required="false">
<cfset var return = "">
<cfif structKeyExists(arguments.passedStruct,"submit")>
<cfset request.credentials.username = arguments.passedStruct.username>
<cfset request.credentials.applicationToLogin =
arguments.passedStruct.applicationToLogin>
-----------
-------------
</cffunction

--------------------------------------------------------------------------------
----
Code to call webservice:

<cfset passedStruct = StructNew()>
<cfset a = StructInsert(passedStruct, "submit", "submit", 1)>
<cfset a = StructInsert(passedStruct, "username", "***@yahoo.com", 1)>
<cfset a = StructInsert(passedStruct, "applicationToLogin", "atccWeb", 1)>
<!---<cfset passedStruct.username ="***@yahoo.com">
<cfset passedStruct.applicationToLogin="atccWeb">--->
<cfoutput>#passedStruct["submit"]#</cfoutput>
<cfinvoke webservice="http://localhost:8500/library/BaseConsole.cfc?wsdl"
method="getWebProfileHTML"
argumentcollection="#passedStruct#"
returnvariable="profilehtml">
</cfinvoke>
<cfoutput>#profilehtml#</cfoutput>
-------------------------------------------------------------------

Error displayed

Web service operation getWebProfileHTML with parameters
{username={***@yahoo.com},submit={submit},applicationToLogin={atccWeb}}
cannot be found.


The error occurred in C:\ColdFusion8\wwwroot\selfprojects\webservices1.cfm:
line 19

17 : method="getWebProfileHTML"
18 : argumentcollection="#passedStruct#"
19 : returnvariable="profilehtml">
20 : </cfinvoke>
21 : <cfoutput>#profilehtml#</cfoutput>
GArlington
2009-03-20 14:24:58 UTC
Permalink
Post by shafiur
How do I call this webservice?
 I am trying to call using this code but it displays an error:?
 Please help me.....
 ACtual webservice
 <cffunction name="getWebProfileHTML" access="remote" output="false"
returntype="string" displayname="getWebProfileHTML">
        <cfargument name="passedStruct" required="false">
Here you define your webservice as accepting 1 (ONE) argument of
UNKNOWN type...
Post by shafiur
        <cfset var return = "">
        <cfif structKeyExists(arguments.passedStruct,"submit")>
                <cfset request.credentials.username = arguments.passedStruct.username>
                <cfset request.credentials.applicationToLogin =
arguments.passedStruct.applicationToLogin>
 -----------
 -------------
 </cffunction
--------------------------------------------------------------------------------
----
 <cfset passedStruct = StructNew()>
 <cfset a = StructInsert(passedStruct, "submit", "submit", 1)>
 <cfset a = StructInsert(passedStruct, "applicationToLogin", "atccWeb", 1)>
 <cfset passedStruct.applicationToLogin="atccWeb">--->
 <cfoutput>#passedStruct["submit"]#</cfoutput>
 <cfinvoke webservice="http://localhost:8500/library/BaseConsole.cfc?wsdl"
                method="getWebProfileHTML"
                argumentcollection="#passedStruct#"
                returnvariable="profilehtml">
                 </cfinvoke>
Here you attempt to call the method with MULTIPLE arguments...
What did you expect? Obviously it can NOT find such method...
Remove <cfargument name="passedStruct" required="false"> statement
from method definition or call it with ONE parameter...
Post by shafiur
 <cfoutput>#profilehtml#</cfoutput>
 -------------------------------------------------------------------
 Error displayed
 Web service operation getWebProfileHTML with parameters
cannot be found.  
line 19
 17 :           method="getWebProfileHTML"
 18 :           argumentcollection="#passedStruct#"
 19 :           returnvariable="profilehtml">
 20 :            </cfinvoke>
 21 : <cfoutput>#profilehtml#</cfoutput>
BKBK
2009-03-28 09:27:14 UTC
Permalink
For a start, add attribute [i]type="Struct"[/i] to the cfargument tag.
byron1021
2009-04-02 00:29:57 UTC
Permalink
Argument is a structure containing all the parameters. Easiest thing to change
is

<cfinvoke webservice="http://localhost:8500/library/BaseConsole.cfc?wsdl"
method="getWebProfileHTML"
returnvariable="profilehtml">
<cfinvokeargument name='passedStruct' value="#passedStruct#">
</cfinvoke>

Alternately, you could do the cfinvoke as is, and change the function with
cfarguments of username, applicationToLogin, and submit.


<cffunction name="getWebProfileHTML" access="remote" output="false"
returntype="string" displayname="getWebProfileHTML">
<cfargument name="username" required="false">
<cfargument name="submit" required="false">
.. but you'd have to edit the rest of the function.

Loading...