开发者

Deploying a salesforce.com flex app without visualforce

SHORT VERSION: I have a Flex app that uses Salesforce.com's API. I am trying to deploy it to a remote server but keep getting "Error during login process." when I try to have it log in to salesforce's servers. What gives?

LONG VERSION (maybe s开发者_开发技巧omeone finds this useful later): I have a flex application that's an add-on for salesforce.com

If I upload it as a static file to salesforce and then embed it in a visualforce page, it works fine. This method uses "loginBySessionId" rather than loginByCredentials.

I would like to be able to run it outside of salesforce's servers. IE, I would like to host the app on my own server and have people enter their credentials in the app and have it login to salesforce's servers. This way, if someone wants to try my application, they do not have to be salesforce administrators and do not have to install the app into a visualforce page.

Here's where the trouble is. If I enter my login information and run it from the compiler, it connects and loads the right data. If I export it as a production release, it still runs fine. However, if I either upload the release files to my own server, or if I transfer them to another computer and run them locally, i get an "Error during login process" Seems some others have had similar issues, but no solutions and nothing new.

Weirder still, if I transfer the project files to another computer and recompile them, it suddenly works. So basically, seems like I have to recompile the app for each computer I plan on running it on, but that's not practical. Even still, I don't see how that could possibly be making a difference, compiling on one vs the other. And yes, same versions of flash, same versions of Flex.

Does anyone have any suggestions on how to resolve this? Am I just misunderstanding something with how to deploy flex applications or is this some screwy thing with the salesforce API and there's a workaround?

As one added thing that makes this problem particularly frustrating is that I can't use the debugger because if I compile it on another computer, it works, so in order for me to get the error I have to build, then transfer to another computer. I feel like this could be a key to the problem, but I'm not sure how.

Here is some applicable code, pretty basic:

<flexforforce:F3WebApplication 
    id="app" statusChanged="statusChangedHandler(event)"       
    loginComplete="loginCompleteHandler(event)" 
    loginFailed="loginFailedHandler(event)" 
    sessionExpired="sessionExpiredHandler(event)" 
    serverUrl="http://na9.salesforce.com/services/Soap/u/19.0" 
    requiredTypes="Account,Contact,Opportunity,Lead,Task,User" />

protected function loginClickHandler( event : MouseEvent ) : void {
    _username = 'LOGIN@LOGIN.COM';
    _password = 'PASSWORD+SECURITY_TOKEN';
    CursorManager.setBusyCursor();
    app.loginByCredentials( _username, _password );
}


To clarify, you probably need something like this on initialization :

flash.system.Security.loadPolicyFile("http://na9.salesforce.com/services/Soap/crossdomain.xml");

The reason it works when you compile it is that a lot of the default security is not applicable when on same machine as compiled. Heck, you can even access the hard drive in paths (like a relative URL path to an image on the hard drive) - try running the swf on another computer and bam- no go.

This is an excellent indicator you're hitting a player / VM security issue :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜