You need to sign in to do that
Don't have an account?
CFMX_DEV
ColdFusion MX Sample Code?
Does anyone have some ColdFusion MX sample code for integration with SF APIs?
Specifically for API Version 2.5: Initial login, setting session headers and subsequent data updates.
I've seen several postings related to this topic but no conclusion was ever presented.
Much appreciated!
Here is some sample code that sets up webservices, adds session ID to the SOAP headers, and performs a sample query.
<cfoutput>
<cfset sfdc = createObject("webservice","#sforceURL#") />
<!--- Developer Login --->
<cfset result = sfdc.login("me@domain.com","#password#") />
<p>session id = #result.getSessionId()#</p>
<p>server URL = #result.getServerURL()#</p>
<!--- create a SOAPHeaderElement called SessionHeader in the SforceService
namespace: --->
<cfset authHeader =
createObject("java","org.apache.axis.message.SOAPHeaderElement")
.init("SforceService", "SessionHeader") />
<!--- add (and populate) a text node called sessionId: --->
<cfset
authHeader.addChildElement("sessionId").addTextNode(result.getSessionId())
/>
<!--- set the entire soap header: --->
<cfset sfdc.setHeader(authHeader) />
<!--- change the endpoint URL to what was returned by the login method: --->
<cfset
sfdc._setProperty("javax.xml.rpc.service.endpoint.address",result.getServerU
RL()) />
<cfset result = sfdc.getUserInfo() />
<p>
User's Organization = <strong>#result.getOrganizationName()#</strong><br>
User's E-mail: <strong>#result.getUserEmail()#</strong><br>
User's UserID: <strong>#result.getUserId()#</strong><br>
User's Full Name: <strong>#result.getUserFullName()#</strong></P>
<cfset objects = sfdc.describeGlobal() />
<cfset nTypes = arrayLen(objects.types) />
<p>Types that can be queried:<cfloop index="i" from="1" to="#nTypes#">
#objects.types[i]#</cfloop></p>
<cfset result = sfdc.query("select FirstName, LastName from Contact") />
<cfset nRecords = arrayLen(result.records) />
<p>Contact records:<cfloop index="i" from="1" to="#nRecords#"> <br
/>#result.records[i].firstName# #result.records[i].lastName#</cfloop></p>
</cfoutput>
Message Edited by eyewell on 06-15-2004 03:06 PM