Skip to main content
Participant
April 17, 2009
Question

Web service invocation?

  • April 17, 2009
  • 3 replies
  • 542 views

Hi,

I have two webservices developed and deployed in coldfusion server(development). Webservices.cfc

I am trying to invoke both these webservices one after other from my local server.

Explanation : first service tries to lock a session variable that references other file(within project), and the second service uses that variable to invoke functions from that referenced file as below?

Question:- Do I have to maintain any session variable during invocation(i.e in webservices3.cfm)?

My thinking:- Please correct me if I am wrong

" I am trying to setup a session in first webserice and during the second webservice invocation I am using that variable. So the session variable should be maintained at ther server side(development server)."

suggest me?

Webservices.cfc

<cffunction

name="setUpWebUserSession" access="remote" output="false" returntype="string" displayname="setUpWebUserSession">

<cfargument name="userName" required="true" default="">

<cfargument name="applicationToLogIn" required="true" default="">

<cfset var isSuccessful = "true">

<cflock scope="session" throwontimeout="true" timeout="120" type="exclusive">

<cfset session.WebUserUI = createObject("component", "org.atcc.webuser.client.presentation.WebUserUI")>//refenceing other file

<cfset session.WebUserUI.init()>

<cfset session.isLoggedIn = true>

</cflock>

<cfreturn isSuccessful>

</cffunction>

<cffunction

name="getProfileHTML" access="remote" displayname="getProfileHTML" output="false" returntype="string">

<cfset var profileHTML = "">

<cfsavecontent variable="profileHTML">

<cfoutput>#session.WebUserUI.getWebProfileHTML()#</cfoutput>//Using the session variable and calling function from webuserui

</cfsavecontent>

<cfreturn profileHTML>

</cffunction>

Webservices3.cfm(code to invoke two webservices)

<cfset

username="muddu_shafi@yahoo.com">

<cfset

applicationToLogin="atccWeb">

<cfinvoke

webservice="http://localhost/CTiWebServicesAPI/ATCC/WebServicesAPI.cfc?wsdl"

method="setUpWebUserSession"

returnvariable="saleshistory">

<cfinvokeargument name="username" value="#username#"/>

<cfinvokeargument name="applicationToLogin" value="#applicationToLogin#"/>

</cfinvoke>

<cfoutput>

#saleshistory#

</cfoutput>

<cfinvoke

webservice="http://localhost/CTiWebServicesAPI/ATCC/WebServicesAPI.cfc?wsdl"

method="getProfileHTML"

returnvariable="profilehtml">

</cfinvoke>

<cfoutput>

#profilehtml#

</cfoutput>

Output:-

true(First webservice executes perfectly)

ErrorCode: 
message: session.WebUserUI.getWebProfileHTML() doesn't exist.
detail: Error at line 1, column 8

 faultActor: 
 faultNode: 
 faultDetail: 
     {http://xml.apache.org/axis/}hostname:ecom1
 ''
The error occurred in C:\ColdFusion8\wwwroot\selfprojects\webservices3.cfm: line 21
19 : <cfinvoke webservice="http://10.80.48.15:8080/CTiWebServicesAPI/ATCC/WebServicesAPI.cfc?wsdl"
20 :            method="getProfileHTML" 
21 :           returnvariable="profilehtml">
22 : </cfinvoke>
23 : <cfoutput>#profilehtml#</cfoutput>

This topic has been closed for replies.

3 replies

ilssac
Inspiring
April 20, 2009

As well as the need for each piece of code to be under the same CF application as defiend by the name string of an <cfapplicaiton name=""...> tag or an this.name property in an Application.cfc pseudo constructor.  The code invokeing the web services must pass the cfid and cftoken values that enable CF to know the incomming request belongs to any previous requests of this 'session'.  Web service calls do not do this, by deault, as a web browser does.  So it is much trickier to maintain a session across multiple web service requests.

April 20, 2009

Session scope is tied to <cfapplication>?  All your files need to speak the same 'session' so each one needs at a minimum a cfapplication tag with the same name set in each for them to use session variables...

Or so I think...

Inspiring
April 17, 2009

variable names can't contain spaces.