1 Reply Latest reply on Feb 18, 2009 8:49 AM by Dan Bracuk

    Help consuming webservice?

      I have two webservices which I am trying to consume one after the other. The first webservice does return a true string, but the second webservice displays an error as it is unable to find the session variable that I setup in the first webservice.
      What should I do? How should I call the session variable when I invoke the webservice?

      first Webservice in a file:

      <cffunction name="setUpWebUserSession" access="remote" output="false" returntype="string" displayname="setUpWebUserSession">
      <cfset isSuccesful="true">
      <cfargument name="userName" required="true" default="">
      <cfargument name="applicationToLogIn" required="true" default="">
      <cflock scope="session" throwontimeout="true" timeout="120" type="exclusive"><!--- --->
      <cfset session.WebUserUI = createObject("component", "org.atcc.webuser.client.presentation.WebUserUI")>
      <cfreturn isSuccesful>
      Second webservice in the same file:-

      <cffunction name="getProfileHTML" access="remote" displayname="getProfileHTML" output="false" returntype="string">
      <cfset var profileHTML = "">
      <cfsavecontent variable="profileHTML">
      <cfreturn application.CTiStringCleaner.getCleanString(profileHTML)>
      <!--- <cfreturn profileHTML> --->

      Error Message from Axis:
      message: session.WebUserUI.getSalesOrderHistorySection() doesn't exist.
      detail: Error at line 1, column 52

      the way I am consuming webservice

      <cfinvoke webservice=""
      <cfinvokeargument name="userName" value="muddu_shafi@yahoo.com">
      <cfinvokeargument name="applicationToLogIn" value="atccWeb">
      <cfoutput> #soo# </cfoutput>
      <cfinvoke webservice=""
      method= "getSaleOrderHistoryHTML"
      <!-- TS024546-->

      First Web service Second webservice
        • 1. Re: Help consuming webservice?
          Dan Bracuk Level 5
          Don't use session variables with webservices. You are asking for trouble.

          In the first webservice, return a structure that includes the string and the value of that session variable. That makes it available to pass as an argument to the 2nd web service.

          Or, if the two webservices are in the same cfc, set up a global variable outside of any functions. Then write a function to give it a value. In your other two functions, put in some if/else logic to see if you have to call that third function. Note that if you choose this method, you'll be wanting to use the createobject way of calling your webservice, instead of cfinvoke. Actually, you probably want to anyhow, this is just another reason.