• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Web service invocation?

New Here ,
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

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>

TOPICS
Advanced techniques

Views

513

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

variable names can't contain spaces.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2009 Apr 20, 2009

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 20, 2009 Apr 20, 2009

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation