Posted By

ChrisCantley on 07/08/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Accessing a webservice


 / Published in: ColdFusion
 

  1. <!---
  2. 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
  3.  
  4. --->
  5.  
  6. <cfset apiLeads = createObject("webservice","https://www.claytonupdatecenter.com/API.cfc?wsdl")>
  7. <cfset getLead = apiLeads.getLeadInfo('blah', '12312')>
  8. <cfdump var="#getLead#">
  9.  
  10.  
  11. <!--- The second way is to use the CFINVOKE tag --->
  12. <cfinvoke
  13. webservice="http://www.claytonupdatecenter.com/API.cfc?wsdl"
  14. method="getLeadInfo"
  15. returnvariable="serviceReturn">
  16. <cfinvokeargument name="key" value="blah"/>
  17. <cfinvokeargument name="leadId" value="12312"/>
  18. </cfinvoke>
  19.  
  20. <Cfdump var="#serviceReturn#" >
  21.  
  22. <!--- and lastly, when all else fails, you can send the request through HTTP, then use WDDX2CFML to turn the returned value into something
  23. you can use.
  24. --->
  25.  
  26. <Cfhttp url="http://www.claytonupdatecenter.com/API.cfc?method=getLeadInfo&key=blah&leadId=12345" />
  27. <cfwddx
  28. action = "wddx2cfml"
  29. input = "#CFHTTP.FileContent#"
  30. output = "serviceReturn" >
  31.  
  32. <Cfdump var="#serviceReturn#" >
  33.  
  34. <Cfoutput query="serviceReturn">
  35. #error#
  36. </Cfoutput>

Report this snippet  

You need to login to post a comment.