+ Start a Discussion
LeonardLeonard 

Trouble integrating Flex

I'm having trouble getting a basic hello-world level Flex app to integrate with a SalesForce Page.

Not sure what the issue is.

 

Here's the SF page. I have the .swf as a Static Resource and I'm passing in the session Id and server url.

 

<apex:page > <!-- Begin Default Content REMOVE THIS --> <h1>Congratulations</h1> This is your new Page <apex:pageBlock title="Active Opportunities"> <apex:flash src="{!$Resource.Factored_Forecast_Control}" width="500" height="300" flashvars="sid={!$Api.Session_ID}&surl={!$Api.Partner_Server_URL_90}"/> </apex:pageBlock> <!-- End Default Content REMOVE THIS --> </apex:page>

 

 ...and here's the Flex piece. It fires a basic LoginRequest. It results in an error and I'm not clear why.

 

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:salesforce="http://www.salesforce.com/" creationComplete="init()"> <mx:Script> <![CDATA[ import com.salesforce.objects.LoginRequest; import com.salesforce.AsyncResponder; import com.salesforce.results.LoginResult; import mx.controls.Alert; public var lr:LoginRequest; public var lar:AsyncResponder = new AsyncResponder(loginSuccess,faultHandler); private function init():void{ lr = new LoginRequest(); lr.session_id = parameters.sid; lr.server_url = parameters.surl; lr.callback = lar; force.login(lr); } private function faultHandler(result:Object):void { for(var i in result){ Alert.show(i + " is " + result[i]); } } private function loginSuccess(result:LoginResult):void{ } ]]> </mx:Script> <salesforce:Connection id="force"/> </mx:Application>

 

 

 

 

Nick1746323Nick1746323

Looks okay to me. What's the error?

 

LeonardLeonard

Hard to tell what the error is.

 

The error I get back has no properties other than a context property with a null value.

 

I'm guessing this is some combination of sandbox/permissions/license issues.

Nick1746323Nick1746323

well you need to be a user with "API Enabled" at least, I believe.

 

Also try this as your fault handler, it might help show the full error:

 

 

private function faultHandler(result:Object):void { Alert.show('fault from operation: ' + ObjectUtil.toString(result)); }

 

 

 

LeonardLeonard

Whew! Huge help. It doesn't like the Session Id. Now, I'm not sure what's wrong with the sessionId I'm passing in.

 

 

flashvars="sid={!$Api.Session_ID}&surl={!$Api.Partner_Server_URL_90}

 

 

 

 

 

fault from operation: (com.salesforce.results::Fault)#0 context = (null) detail = (Object)#1 fault = (Object)#2 exceptionCode = "INVALID_SESSION_ID" exceptionMessage = "Invalid Session ID found in SessionHeader: Illegal Session" xsi:type = "sf:UnexpectedErrorFault" faultcode = "sf:INVALID_SESSION_ID" faultstring = "INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session"

 

 

 

Nick1746323Nick1746323
Ah, hmm, normally that would indicate that the session has expired, but in this situation that would be impossible. It may be related to some of the options under "Session Settings" in your org. otherwise no idea sorry
LeonardLeonard
Thanks for the help. I'll look into the session issue.