Return to Snippet

Revision: 28429
at July 8, 2010 06:14 by ChrisCantley


Initial Code
<!---
There are a few ways to invoke a web service.  The first is to create the object and then pass in the parameters like a function
 
 --->

<cfset apiLeads = createObject("webservice","https://www.claytonupdatecenter.com/API.cfc?wsdl")>
<cfset getLead = apiLeads.getLeadInfo('blah', '12312')>
<cfdump var="#getLead#">


<!---  The second way is to use the CFINVOKE tag --->
<cfinvoke 
  webservice="http://www.claytonupdatecenter.com/API.cfc?wsdl"
  method="getLeadInfo"
  returnvariable="serviceReturn">
    <cfinvokeargument name="key" value="blah"/>
    <cfinvokeargument name="leadId" value="12312"/>
</cfinvoke>

<Cfdump var="#serviceReturn#" >

<!--- and lastly, when all else fails, you can send the request through HTTP, then use WDDX2CFML to turn the returned value into something 
you can use.
--->

<Cfhttp url="http://www.claytonupdatecenter.com/API.cfc?method=getLeadInfo&key=blah&leadId=12345" />
<cfwddx 
    action = "wddx2cfml" 
    input = "#CFHTTP.FileContent#" 
    output = "serviceReturn" >

<Cfdump var="#serviceReturn#" >

<Cfoutput query="serviceReturn">
#error#
</Cfoutput>

Initial URL


Initial Description


Initial Title
Accessing a webservice

Initial Tags


Initial Language
ColdFusion