I'm using a webservice that requires that i first call a Login method,
extract the returned cookie and pass that in subsequent requests. The object
that brokers calls to this service is persisted in the application scope
(via coldspring) so as not to require a call to Login for every request to
the web service.  However, what i'm after is the SOAP xml returned in the
response, not the java objects returned by cfinvoke, and to get at that i
need to call a method on the cf webservice object after cfinvoke has called
the method.  My assumption is that i'm going to need to single-thread access
to the webservice object within the call method, otherwise i may get the xml
from a request made in a different thread, but this is going to cause a
severe bottleneck at a very busy point.
The code snippet below should give you an idea of what i'm upto.

I wondered if anyone might have any thoughts on whether this is the best way
to handle this scenario?

Cheers, Chris

<cffunction name="init" access="public" output="false" returntype="any">
<cfargument name="username" type="string" required="true" />
<cfargument name="password" type="string" required="true" />
<cfset var my = structnew() />
 <cfset variables.ws = createobject("webservice", variables.wsdlurl) />
<cfset variables.ws.setMaintainSession(true) />

<cfset my.ret = ws.Login(username, password) >
 <cfset variables.cookie =
variables.ws._getCall().getMessageContext().getProperty("Cookie") />
<cfset variables.cookie = listToarray(arrayToList(variables.cookie)) />
 <cfset variables.ws._setProperty("Cookie", variables.cookie) />

<cfreturn this />
</cffunction>

<cffunction name="call" access="private" output="false" returntype="any">
<cfargument name="method" />
<cfargument name="args" />
 <cfset var my = structnew() />

 <cflock name="#variables.id#-call_lock">
 <cfinvoke webservice="#variables.ws#" method="#method#"
returnvariable="my.ret">
 <cfloop collection="#args#" item="my.i">
 <cfinvokeargument name="#my.i#" value="#args[my.i]#" />
 </cfloop>
 </cfinvoke>

 <cfset my.ret
= 
variables.ws._getCall().getMessageContext().getResponseMessage().getSOAPPartAsString()
/>

 </cflock>

<cfreturn parseXml(my.ret) />
</cffunction>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to