function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ConnectEduConnectEdu 

Setting SessionID using Cold Fusion CFSCRIPT and sForce API LoginResults

I am attempting to do what I'm sure a lot of Cold Fusion MX 6.1 developers want to do.  Connect using the sforce WSDL and do something OTHER than a successful login.  What I need in CFML is an equvalent of the following C# code:

BEGIN C#:

private SforceService sForce25 = new SforceService();
LoginResult ret;
ret = sForce25.login(_userName, _password);

sForce25.SessionHeaderValue = new SessionHeader();
sForce25.SessionHeaderValue.sessionId = ret.sessionId;
sForce25.Url = ret.serverUrl;
sForce25.SessionHeaderValue.sessionId = Request.QueryString["sid"].ToString();

END C#

Here is what I have so far in CFML:

BEGIN CFML:


 // create service:
 sfapi = CreateObject("webservice", "salesforcewsdlURL");
 loginResult = sfapi.login(name@domain.com, "password");



 loginResult: #loginResult#

 serverUrl: #loginResult.serverUrl#

 sessionID: #loginResult.sessionID#

 userID: #loginResult.userID#

END CFML

Note that I'd like to use the results from the initial login to fuel setting up the sessionID for the subsequent calls.  I'm sure someone out there has accomplished this.  Note to the moderators - if I can't resolve this issue, it is unlikely that we will decide to purchase the Enterprise version of SalesForce.

ConnectEduConnectEdu

To put it another way, how does one accomplish using CFML what the SForceService exception handler clearly states?

"Could not perform web service invocation "getUserInfo" because AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server faultSubcode: faultString: Destination URL not reset. The URL returned from login must be set in the SforceService faultActor: faultNode: faultDetail: {urn:fault.enterprise.soap.sforce.com}fault: <sf:exceptionCode>UNKNOWN_EXCEPTION</sf:exceptionCode> <sf:exceptionMessage>Destination URL not reset. The URL returned from login must be set in the SforceService</sf:exceptionMessage>"

adamgadamg
do you know how to change the SOAP endpoint (URL) manually in CF? that is what sforce is asking you to do..

..see if this helps:

http://www.macromedia.com/support/coldfusion/ts/documents/webservices_header.htm

Message Edited by adamg on 06-10-2004 02:59 PM

serattsseratts
I have attempted the following:

objSalesForceAPI = createObject( "component", "com.salesforce.salesforce_connector" );
objBinding = objSalesForceAPI.loginCFWs();

// get the session ID
sessionID = objBinding.loginResult.getSessionID();

// set the cachedEndpoint
objBinding.soapBindingStub._setProperty("cachedEndpoint", objBinding.loginResult.getServerURL());

//writeOutput(objBinding.soapBindingStub._getProperty("cachedEndpoint"));

// create a session header object to pass back
sh = createObject("java", "_SessionHeader");
sh.setSessionID(sessionID);

// create a new service instance and initialize to pass in with session header
qName = createObject("java", "javax.xml.namespace.QName");
qName.init("urn:enterprise.soap.sforce.com", "SforceService");
URI = qName.getNamespaceURI();

// add header
objBinding.soapBindingStub.setHeader(URI, "SessionHeader", sh);

When I then call:
objBinding.soapBindingStub.getHeaders();

I receive an array with one index of the headers. So I know that I am setting the headers correctly into the object. I also can do a _getPropery('cachedEndpoint') and it returns the correct URL.

My next call to the service returns the same Error:
Destination URL not reset. The URL returned from login must be set in the SforceService

I am running MX7 which has the latest code (includes the links from the previous posts)