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
jchanowitzjchanowitz 

Flex toolkit and cross domain issues

Hi,
 
I'm trying to use the flex toolkit.  I can run the salesforce.mxml app with no problems locally, but receive security sandbox errors when running from a server.  I can see the apex login call is finding a cross-domain.xml file, but i still receive the violation.
 
The domain the toolkit requests data from is: .../services/Soap/u/9.0
 
but the file is at  .../services/Soap/u/cross-domain.xml.
 
Does anyone know if it's location is an issue, or is there something else I'm doing wrong?
 
Thanks.  It sure seems like a great tool if I can deploy it.
 
Jay
mibropmibrop
I'm experiencing this same issue (posted my report several days ago).

Anyone experienced this who found a solution?

Thanks,
Mike
Seattle
jchanowitzjchanowitz
I wonder if the file's been given the wrong name.  I've never seen it spelled with a hyphen.  Anyone here from SalesForce that can get the file renamed to "crossdomain.xml"?
jchanowitzjchanowitz
Yes, it's login.  Like I said, it works fine when I open it locally.  Here's the error trace when I open the same file through IIS using localhost.  I'd love to get this working.  Any help is greatly appreciated.
 
Thanks
 
(mx.rpc::Fault)#0
  errorID = 0
  faultCode = "Channel.Security.Error"
  faultDetail = "Destination: DefaultHTTP"
  faultString = "Security error accessing url"
  message = "faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'"
  name = "Error"
  rootCause = (flash.events::SecurityErrorEvent)#1
    bubbles = false
    cancelable = false
    currentTarget = (flash.net::URLLoader)#2
      bytesLoaded = 0
      bytesTotal = 0
      data = (null)
      dataFormat = "text"
    eventPhase = 2
    target = (flash.net::URLLoader)#2
    text = "Error #2048: Security sandbox violation: http://localhost/IntuitPortal/salesforce.swf cannot load data from http://www.salesforce.com/services/Soap/u/9.0."
    type = "securityError"
 
 
SuperfellSuperfell
Does the toolkit load the cross-domain.xml over HTTPS ? it might be that you have a mismatched https/http issue. (Your login call appears to be HTTP, definitly not good pratice)
jchanowitzjchanowitz

I'm just trying to do the toolkit's version of "Hello World" from my workstation's IIS localhost instance.  It doesn't look like there's any https in the transaction.  Here's the debugEvent's  debugString from my logon request:

App Domain = null
Api Server name = www.salesforce.com
_internalServerUrl set to http://www.salesforce.com/services/Soap/u/9.0
loading the policy file: http://www.salesforce.com/services/Soap/u/cross-domain.xml
sandbox = remote
transport.url = http://www.salesforce.com/services/Soap/u/9.0

It's wierd. It seems to show the policy file was successfully loaded, but I still get the above sandbox error.  Maybe just sticking a little proxy server between the flex client and SalesForce, instead of using the toolkit's library, is a better way to go.  It just seems like such a fast and effective way to deploy simple CRUD apps over the Internet.

 

 

SuperfellSuperfell
Ahhh, the problem is that, the path you have to the cross-domain file it not correct for WWW, its correct for one of the application instances, but not for login via www. I'm pretty sure there is a cross domain policy file for www, but i'm not sure exactly what its location is.
Ron HessRon Hess
The cross domain file is differently spelled on WWW, i'll adjust the library and re-publish.

that is blocking the login from succeding

if you have a session id and a server url you should be able to use the API, but until there is a policy file for www you cannot use login()

local file works because the "local " sandbox is trusted
running from an scontrol works because the domain is the same

it's only running from a non-salesforce server that you would see this.

here is the login code, probably should be using https by default:
Code:
   public function loginWithCredentials(username:String, password:String, callback:IResponder):void {
            if (this.serverUrl == null)
            {
                this.serverUrl = "http://www.salesforce.com/services/Soap/u/9.0";
            }
      var arg1:Parameter = new Parameter("username", username, false);
   var arg2:Parameter = new Parameter("password", password, false);
      this.isLoggingIn = true;
      
      invoke("login", [arg1, arg2], false, callback);
    }

 

Message Edited by Ron Hess on 06-06-2007 02:49 PM

MitchGrassoMitchGrasso
I'm somewhat confused by the resolution of this thread and I am having similar issues when attempting to login from my flex application.

Is it currently possible to login using credentials from a flex application running on a webserver external to salesforce.com? If so, how?

thanks!
mitch

jchanowitzjchanowitz
With Ron's help, I was actually able to get this working by tweaking the Connection class in the toolkit src and recompiling the library.  It's not very pretty, and I'm sure the giant brains at Salesforce and Adobe are working on a more elegant solution even as we speak ;).  First the cross domain policy file is at

http://www.salesforce.com/services/crossdomain.xml, so you need to change the loginWIthCredentials function to load the policy file:

if (this.serverUrl == null)

{

this.serverUrl = "http://www.salesforce.com/services/Soap/u/9.0";

var policyUrl:String = "http://www.salesforce.com/services/crossdomain.xml";

Util.debug(this, "loading the policy file: " + policyUrl);

Security.loadPolicyFile(policyUrl);

Util.debug(this, "www sandbox = " + Security.sandboxType);

}

That gets you logged in (assuming you're using http, which I'm doing off of localhost; if using https then change accordingly)

Then to actually do anything - if using http - I needed to load the policy file to the api server at the end of loginWithCredentials function (assuming you're hitting na3):

Security.loadPolicyFile("http://na3-api.salesforce.com/services/Soap/u/cross-domain.xml");

Lastly, in the invoke function, I needed to strip out the returned https internal server to http:

if (intServerUrl == null) {

// Util.debug(this, "intServerUrl is null");

intServerUrl = _internalServerUrl;

if (intServerUrl.substr(0,5) == "https") {

intServerUrl = "http" + intServerUrl.substr(5);

}

Hope this helps. 

Ron HessRon Hess
The latest checked in source out on the SVN trunk ( sourceforge) has a fix / working version  that allows you to host your SWF on your website and access the cross domain files properly, as of now one is named crossdomain.xml and the other cross-domain.xml, which was confusing for a bit, and we hope to correct at some point.

it's a bit tricky, since the server you are on and the endpoint you talk to must be exactly the same protocol, I had to add a getter and setter for the protocol which can be one of  1)http  2)https.  all my testing was done on http, using an apache localhost on my mac.

this code has not been re-built into a library yet, I expect to update that soon.
until then, if you check out the src , and build using the ANT build file ( compileSWF target) you can build your own working version.

Message Edited by Ron Hess on 07-26-2007 04:19 PM

jev007jev007
I am running into the same issue now and am wondering if the "brains" actually created something better to handle this.

Thanks!
fullvaluefullvalue
I am having an issue like this using the latest toolkit.

Can anyone help?

Thanks!
jchanowitzjchanowitz
I'm not sure what error you're getting but you need to make sure that you're appending your security token to the end of your password (use the same credentials that you use to access your SF instance in the Force ide).  Also, if running from localhost, you're probably using http, so you need to place the following line prior to your login call:
 apex.protocol = "http";
 
fullvaluefullvalue
Thanks so much for the reply.  I really need to figure this out.  Here is my login function.  I tried adding the code you suggested but I am still getting the following error.


Code:
private function login():void {
  var lr:LoginRequest = new LoginRequest({
 /* server_url : Application.application.parameters.server_url, 
  session_id : Application.application.parameters.session_id,
 */ username : 'myemail@email.com', 
  password : 'xxxxxx9KYz1Hmt96xxxQcNVpjaq61',    
  callback : new AsyncResponder(function (result:Object):void{ 
  })});
  apex.protocol = "http"; 
  apex.login(lr);   
 }

 

(com.salesforce.events::ApexFaultEvent)#0

  bubbles = false

  cancelable = true

  context = (null)

  currentTarget = (null)

  eventPhase = 2

  fault = (mx.rpc::Fault)#1

    errorID = 0

    faultCode = "Channel.Security.Error"

    faultDetail = "Destination: DefaultHTTP"

    faultString = "Security error accessing url"

    message = "faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'"

    name = "Error"

    rootCause = (flash.events::SecurityErrorEvent)#2

      bubbles = false

      cancelable = false

      currentTarget = (flash.net::URLLoader)#3

        bytesLoaded = 0

        bytesTotal = 0

        data = (null)

        dataFormat = "text"

      eventPhase = 2

      target = (flash.net::URLLoader)#3

      text = "Error #2048"

      type = "securityError"

  message = (mx.messaging.messages::ErrorMessage)#4

    body = (Object)#5

    clientId = "DirectHTTPChannel0"

    correlationId = "177820BC-C1C2-E842-7FE6-C8EB287E98CD"

    destination = ""

    extendedData = (null)

    faultCode = "Channel.Security.Error"

    faultDetail = "Destination: DefaultHTTP"

    faultString = "Security error accessing url"

    headers = (Object)#6

    messageId = "BDC545D7-8793-9DA5-3F56-C8EB288E66D4"

    rootCause = (flash.events::SecurityErrorEvent)#2

    timestamp = 0

    timeToLive = 0

  messageId = "BDC545D7-8793-9DA5-3F56-C8EB288E66D4"

  target = (null)

  token = (mx.rpc::AsyncToken)#7

    message = (mx.messaging.messages::HTTPRequestMessage)#8

      body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urn:partner.soap.sforce.com"/><se:Body><query xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"><queryString>Select Id, Email From Contact where Email ='joeblow@email.com'</queryString></query></se:Body></se:Envelope>"

      clientId = (null)

      contentType = "text/xml; charset=UTF-8"

      destination = "DefaultHTTP"

      headers = (Object)#9

        DSEndpoint = "direct_http_channel"

      httpHeaders = (Object)#10

        Accept = "text/xml"

        SOAPAction = """"

        X-Salesforce-No-500-SC = "true"

      messageId = "177820BC-C1C2-E842-7FE6-C8EB287E98CD"

      method = "POST"

      recordHeaders = false

      timestamp = 0

      timeToLive = 0

      url = "http://www.salesforce.com/services/Soap/u/11.0"

    responders = (Array)#11

      [0] (::SalesForceResponder)#12

    result = (null)

  type = "fault"





Message Edited by fullvalue on 03-19-2008 02:24 PM
jchanowitzjchanowitz
Why is the soap message in your error showing a query instead of the login?  You may want to try to add a fault handler to the AsyncResponder in your login as well, to see what's coming back there, just an inline function that pops an Alert.show(ObjectUtil.toString(fault)). 
fullvaluefullvalue
here it is.

(com.salesforce.events::ApexFaultEvent)#0
  bubbles = false
  cancelable = true
  context = (null)
  currentTarget = (null)
  eventPhase = 2
  fault = (mx.rpc::Fault)#1
    errorID = 0
    faultCode = "Channel.Security.Error"
    faultDetail = "Destination: DefaultHTTP"
    faultString = "Security error accessing url"
    message = "faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'"
    name = "Error"
    rootCause = (flash.events::SecurityErrorEvent)#2
      bubbles = false
      cancelable = false
      currentTarget = (flash.net::URLLoader)#3
        bytesLoaded = 0
        bytesTotal = 0
        data = (null)
        dataFormat = "text"
      eventPhase = 2
      target = (flash.net::URLLoader)#3
      text = "Error #2048"
      type = "securityError"
  message = (mx.messaging.messages::ErrorMessage)#4
    body = (Object)#5
    clientId = "DirectHTTPChannel0"
    correlationId = "E25F8C1C-225A-C911-6C21-C9CCB67FBDA9"
    destination = ""
    extendedData = (null)
    faultCode = "Channel.Security.Error"
    faultDetail = "Destination: DefaultHTTP"
    faultString = "Security error accessing url"
    headers = (Object)#6
    messageId = "FD4255E6-9E9D-B637-2ADE-C9CCB6EC6A77"
    rootCause = (flash.events::SecurityErrorEvent)#2
    timestamp = 0
    timeToLive = 0
  messageId = "FD4255E6-9E9D-B637-2ADE-C9CCB6EC6A77"
  target = (null)
  token = (mx.rpc::AsyncToken)#7
    message = (mx.messaging.messages::HTTPRequestMessage)#8
      body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urn:partner.soap.sforce.com"/><se:Body><login xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"><username>xxxxxxx@xxxxxx.com</username><password>xxxxxxx1Hmt965WUqQcNVpjaq61</password></login></se:Body></se:Envelope>"
      clientId = (null)
      contentType = "text/xml; charset=UTF-8"
      destination = "DefaultHTTP"
      headers = (Object)#9
        DSEndpoint = "direct_http_channel"
      httpHeaders = (Object)#10
        Accept = "text/xml"
        SOAPAction = """"
        X-Salesforce-No-500-SC = "true"
      messageId = "E25F8C1C-225A-C911-6C21-C9CCB67FBDA9"
      method = "POST"
      recordHeaders = false
      timestamp = 0
      timeToLive = 0
      url = "http://www.salesforce.com/services/Soap/u/11.0"
    responders = (Array)#11
      [0] (::SalesForceResponder)#12
    result = (null)
  type = "fault"
jchanowitzjchanowitz

Well it sure looks like to me that for whatever reason, you're not finding the cross domain policy file for the login end point.  I just pulled the latest toolkit today, and had no problem.  Just to be clear, here's the steps I took to get things working:

  1. I downloaded the toolkit from SourceForge dated Feb 23.
  2. I created a new Flex 3 project in Flex Builder called salesforce, as a web application with no server type.
  3. I dragged the salesforce.mxml file from the test/flex2 directory from the toolkit to the src folder of my project, overwriting the one FlexBuilder created for me.
  4. I dragged the as3SalesForce.swc from the bin dir in the toolkit to the libs folder in my project.
  5. I commented out the convertLead function body, since I didn't bring LeadLookup class along.
  6. I changed to my login credentials in the login method.
  7. I built and ran the app.

That runs it locally with no need for a cross domain file.  I then:

  1. Created a virtual directory using IIS, pointing to the bin-debug folder for my Flex project, calling it testSF.
  2. I added the apex.protocol = "http" line before the apex.login call
  3. In Flex builder, in project properties, Flex Build Path, I added http://localhost/testSF/ to the Output Folder URL text box.
  4. I ran the app again, and still logged in.

Can you sucessfully do that?  If not, then there may be something about where your account is located, that requires a different cross domain file that the toolkit is using.  If you can, it should give you a starting point to whatever else you're trying to do.

 

fullvaluefullvalue
Here is what I did.
  1. I created a new flex project in Flex builder 2.
  2. I added the as3SalesForce.swc to the build path
  3. I dragged the salesforce.mxml file over to the project. overwrote the one Flex built for me.
  4. I commented out the convertLead function body
  5. I changed to my login credentials in the login method
  6. I built and ran the app.
It ran fine. I was able to login.

Next, I copied the bin folder to a network drive and run the HTML that loads the swf.  I couldn't login.  I tried that with and without apex.protocol = "http".

jchanowitzjchanowitz

I can't help with running it off a network drive.  All I can suggest is to try it off a web server directly, like I suggested.  If that works, you need help with understanding the Flash Player's security model and why it doesn't let you in from the folder (if in fact you need to run it from there).  If the web server doesn't work, then you need to look into why the default url in the toolkit for the cross domain file isn't working for your login.

Good luck.

fullvaluefullvalue
I do appricate your help.  I do have an instance on a web server, just thought it should work either way.  It looks like this error is "Error #2032: Stream Error. URL: http://www.salesforce.com/services/Soap/u/11.0".


(com.salesforce.events::ApexFaultEvent)#0

  bubbles = false

  cancelable = true

  context = (null)

  currentTarget = (null)

  eventPhase = 2

  fault = (mx.rpc::Fault)#1

    errorID = 0

    faultCode = "Server.Error.Request"

    faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.salesforce.com/services/Soap/u/11.0"]. URL: http://www.salesforce.com/services/Soap/u/11.0"

    faultString = "HTTP request error"

    message = "faultCode:Server.Error.Request faultString:'HTTP request error' faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.salesforce.com/services/Soap/u/11.0"]. URL: http://www.salesforce.com/services/Soap/u/11.0'"

    name = "Error"

    rootCause = (flash.events::IOErrorEvent)#2

      bubbles = false

      cancelable = false

      currentTarget = (flash.net::URLLoader)#3

        bytesLoaded = 0

        bytesTotal = 0

        data = (null)

        dataFormat = "text"

      eventPhase = 2

      target = (flash.net::URLLoader)#3

      text = "Error #2032: Stream Error. URL: http://www.salesforce.com/services/Soap/u/11.0"

      type = "ioError"

  message = (mx.messaging.messages::ErrorMessage)#4

    body = (Object)#5

    clientId = "DirectHTTPChannel0"

    correlationId = "026E48D3-1BFD-8AA6-A5D6-CDE8A1C8B7D8"

    destination = ""

    extendedData = (null)

    faultCode = "Server.Error.Request"

    faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.salesforce.com/services/Soap/u/11.0"]. URL: http://www.salesforce.com/services/Soap/u/11.0"

    faultString = "HTTP request error"

    headers = (Object)#6

    messageId = "154CD995-435D-2011-47FB-CDE8A2A25895"

    rootCause = (flash.events::IOErrorEvent)#2

    timestamp = 0

    timeToLive = 0

  messageId = "154CD995-435D-2011-47FB-CDE8A2A25895"

  target = (null)

  token = (mx.rpc::AsyncToken)#7

    message = (mx.messaging.messages::HTTPRequestMessage)#8

      body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urnartner.soap.sforce.com"/><se:Body><login xmlns="urnartner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"><username>xxxxxxxx@xxxxxx.com</username><password>xxxxxxxxxxxxx9KYz1Hmt965XXXXQcNVpjaq61</password></login></se:Body></se:Envelope>"

      clientId = (null)

      contentType = "text/xml; charset=UTF-8"

      destination = "DefaultHTTP"

      headers = (Object)#9

        DSEndpoint = "direct_http_channel"

      httpHeaders = (Object)#10

        Accept = "text/xml"

        SOAPAction = """"

        X-Salesforce-No-500-SC = "true"

      messageId = "026E48D3-1BFD-8AA6-A5D6-CDE8A1C8B7D8"

      method = "POST"

      recordHeaders = false

      timestamp = 0

      timeToLive = 0

      url = "http://www.salesforce.com/services/Soap/u/11.0"

    responders = (Array)#11

      [0] (::SalesForceResponder)#12

    result = (null)

  type = "fault"


fullvaluefullvalue
OK I got it to work in the middle of everything and different combinations I found one that worked. 

If I use the apex.protocol = "http" and did not use my security token it worked? 

Not sure I was testing with a dev login..

Anyways that a lot for taking time to help!

Johny MeenJohny Meen
I've experienced the same issue looking now for fix
spotify downloader (https://spotytomp3.com)