This content has been marked as final. Show 4 replies
OK, from reading the HORRIBLE adobe doc's on data services, I am thinking that I just need to alter the below files.... but it still doesn't work. I get a "No destination 'Employee' exists in service flex.data.DataService" error when running the application...... what am I missing?????:
1. add call to dataservice in the mxml file:
<"mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
<mx:DataService id="ds" destination="Employee" conflict="logEvent(event)" fault="logEvent(event)" message="logEvent(event)"/>
<mx:VDividedBox width="800" height="100%">
<mx:Panel title="Employee::getEmployees()" width="800"
2. alter the data-management-config.xml to map the data service id to the java class file
3. The com.theriabook.datasource.EmployeeAssembler java class abstracts the EmployeeDataServiceDAO class which contains the call to the j2ee connection pool:
conn = JDBCConnection.getConnection("jdbc/theriabook");
if( logger.isDebugEnabled() ) logger.debug(" SQL: "+sql);
stmt = conn.prepareStatement(sql);
FDS is a Java web app that you can think of as having 3 layers:
1. A set of endpoints that clients connect to in order to send and recieve data and messages. The HTTP and AMF endpoints are implemented as a servlet. The RTMP endpoint is an NIO socket server.
2. A core message broker that takes inbound messages and routes them to their target service destination and routes responses back out to connected clients.
3. A service layer with destinations that process these messages from clients and if necessary return a response. Each service exposes specific destinations. In the case of the remoting service each destination is a Java object exposes for RPC, in messaging each destination is a topic to publish to or subscribe to, in the data service each destination is backed by an assembler that manages a specific entity type in your domain model, etc.
In the data service case you can connect to a database either via the HibernateAssembler or a custom assembler within which you could talk to a DAO layer or manage CRUD ops directly. Your assembler receives change objects for creates, updates, deletes and the way you access your datastore is up to you. The intent of the data service is to act as a layer on top of an existing Java domain model on the server that allows Flash clients to interact with it directly.
Hopefully that clarrifies the general picture a bit.
Regarding the error you're hitting, if that's a runtime error being thrown on the client it's because the configuration information compiled into the swf doesn't contain the "Employee" destination you've added. How are you compiling your MXML app? If you're compiling in FlexBuilder or at the command line are you referencing your services-config.xml file using the -services option?
What do you mean the configuration information is compilied into the swf? I thought the whole purpose of the config file was that it was kept outside the swf in the data-management-config.xml ?
The configuration files are used for two purposes.
1. To configure the server portion of FDS
2. A subset of the configuration data is injected into compiled swfs to allow you to reach destinations on the server over their supported channels/endpoints.
Taking your example: <mx:DataService id="ds" destination="Employee" ...
Without injecting some of the configuration info into the swf, there's no way for the DataService component to know how or where to reach the "Employee" destination.
So you need to compile your swf using the -services compiler option: -services=<path to your services-config.xml file>