You need to sign in to do that
Don't have an account?
MAvdi
Do I need bridge to connect Flex and Apex?
Hi there,
Im new to salesforce, and my company has asked me to develope a salesforce application that anyone can search throught their online publication without loging in to salesforce. that means I need to create a web application that connects to salesforce database.
I've been reading about this for 3 days now. I see flex can be used to connect to apex without any problem, however in all the examples I've seen, flex is in a s-control. My application needs to be stand alone.
Just to make my mind clear and get me going: Can I connect to Apex from flex without anything like Java to establish connection?
Thank you
Im new to salesforce, and my company has asked me to develope a salesforce application that anyone can search throught their online publication without loging in to salesforce. that means I need to create a web application that connects to salesforce database.
I've been reading about this for 3 days now. I see flex can be used to connect to apex without any problem, however in all the examples I've seen, flex is in a s-control. My application needs to be stand alone.
Just to make my mind clear and get me going: Can I connect to Apex from flex without anything like Java to establish connection?
Thank you
Can you pls give me a hint on how to do this ? I have a similar requirement and I tried connecting to SalesForce Objects doing some action script coding like :
import com.salesforce.objects.LoginRequest;
var lrLogin:LoginRequest = new LoginRequest(
{
server_url:_amLocator.csConnect.sServerURL,
session_id:_amLocator.csConnect.sSessionId,
username:_amLocator.user.sUsername,
password:_amLocator.user.sPassword,
callback:new AsyncResponder(_result, _fault)
}
)
I call this Action Script from a MXML .. but what should be the ServerURL and Session id that I need to pass ? pls help or let me know if you have some samples ??
Thanks,
Arun B
First download Salesforce Flex toolkit
http://wiki.apexdevnet.com/index.php/Flex_Toolkit
there you will find a sample applicaiton which will answer all you questions
Thanks for your prompt response. I did download the flex tool kit and tried to run the samples in that. But I get the following error message when the app is tring to connect to/retrieve data from Sales Force.
urrentTarget = (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: https://www.salesforce.com/services/Soap/u/9.0"
type = "ioError"
headers = (null)
message = (mx.messaging.messages::ErrorMessage)#4
body = (Object)#5
clientId = "DirectHTTPChannel0"
correlationId = "000961F9-2668-F82C-5D73-7E8E05FAA7DC"
destination = ""
extendedData = (null)
faultCode = "Server.Error.Request"
faultDetail = "Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: https://www.salesforce.com/services/Soap/u/9.0"]. URL: https://www.salesforce.com/services/Soap/u/9.0"
faultString = "HTTP request error"
headers = (Object)#6
messageId = "A336B450-FD66-0556-79E4-7E8E0E1DDA74"
rootCause = (flash.events::IOErrorEvent)#2
timestamp = 0
timeToLive = 0
messageId = "A336B450-FD66-0556-79E4-7E8E0E1DDA74"
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>theusername</username><password>pwd</password></login></se:Body></se:Envelope>"
I am very sure that I am doing some basic mistake here .. but not sure where. Can you pls help if you know the root cause of the problem ? My actual MXML code is as below (the same code runs fine if I defined the SWF as an s-control and run it from salesforce.com; but what I am trying now is to run this as a standalone flex app).
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="login(event)" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:salesforce="http://www.salesforce.com/">
<salesforce:Connection id="apex" serverUrl="https://www.salesforce.com/services/Soap/u/9.0" />
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import com.salesforce.results.QueryResult;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import com.salesforce.AsyncResponder;
import com.salesforce.objects.LoginRequest;
private function login(event:Event):void {
//var lr:LoginRequest = new LoginRequest();
//lr.username = "arun.balasubramanian@proservondemand.com";
//lr.password = "haap04";
//lr.callback = new AsyncResponder(loadData, handleFault);
var lr:LoginRequest = new LoginRequest( {
username : <useid>, // put your own info here to test standalone
password : <pwd>, // put your own info here to test standalone
callback : new AsyncResponder(loadData, handleFault)
} );
// Util.debug(this, 'apex.login ( ' +ObjectUtil.toString(lr) +'\n);' );
apex.login(lr);
// apex.login((lr.username, lr.password, lr.callback);
}
[Bindable]
private var tmp:ArrayCollection = new ArrayCollection();
[Bindable]
private var activityHistory:ArrayCollection = new ArrayCollection();
private function handleFault(fault:Object):void {
Alert.show(ObjectUtil.toString(fault));
}
private function loadData(lr:Object):void {
apex.query("Select Id from Account where name like 'new account%' limit 1'", new AsyncResponder(
function(qr:QueryResult):void {
if (qr.size > 0) {
tmp = qr.records;
activityHistory = tmp.getItemAt(0).ActivityHistories.records;
}
},
handleFault)
);
}
]]>
</mx:Script>
<mx:DataGrid dataProvider="{activityHistory}" width="587" x="10" height="386" y="10">
<mx:columns>
<mx:DataGridColumn dataField="Id"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
I would truly appreciate your help here.
Thats because of your security setting
As I learned, you have 2 ways to access the salesforce.
Either from your localhost, or running the standalone swf file which I think this is your case
In case you put your file in localhost you need to change the access setting after the connection is initiated. you have to change your connection access to http by adding protocol property
however, if you just press "Run" button on your flex builder, you have to do the following
go to ip-address.com to find out your own ip address, copy it...
log into your salesforce and go to setup>Administration Setup> Network access
in trusted IP ranges click "new" and enter a range that contains your ip
save and try again, it should work
Regards,
Arun B