Community   SpringSource   Projects    Downloads    Documentation    Forums    Training   Exchange   Blogs

Go Back   Spring Community Forums > Core Spring Projects > Spring BlazeDS Integration

Reply
 
Thread Tools Display Modes
  #1  
Old Dec 23rd, 2008, 03:52 AM
jettro jettro is offline
Senior Member
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 150
Default Configuring the flex app

Hi,
I am trying to convert a sample of mine but I think I am missing something. The docs are talking about the configuration of the services in services-config.xml and remoting-config.xml. The remoting.xml can be pretty much left with some defaults. You do not have to configure the destinations.

In the log files I can see this going for the server side. I see that the configured classes are used. However, I am having some problems at the client. There I cannot find the destinations. Am I doing something wrong? Should I now configure the client differently from the server?

Following my code for the configuration, the commented part is the bean now exposed using the spring integration.
Code:
<service id="remoting-service"
         class="flex.messaging.services.RemotingService">

    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"
                            default="true"/>
    </adapters>

    <default-channels>
        <channel ref="my-amf"/>
    </default-channels>

    <!--<destination id="bookManager">-->
    <!--<properties>-->
    <!--<factory>spring</factory>-->
    <!--<source>bookManager</source>-->
    <!--</properties>-->
    <!--</destination>-->

    <destination id="authenticationHelper">
        <properties>
            <source>nl.gridshore.samples.books.web.security.AuthenticationHelper</source>
        </properties>
    </destination>

</service>
If I change this for the client into:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
         class="flex.messaging.services.RemotingService">

    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"
                            default="true"/>
    </adapters>

    <default-channels>
        <channel ref="my-amf"/>
    </default-channels>

    <destination id="remoteBookManager"/>

    <destination id="authenticationHelper">
        <properties>
            <source>nl.gridshore.samples.books.web.security.AuthenticationHelper</source>
        </properties>
    </destination>

</service>
Than it all seems to work, no I have the problem I cannot share config files, Allthough I like it that I only need to define the destinations without any hassle of factories etc. I still need to know the name of the bean that is exposed. It feels like something that cannot be overcome by the spring blazeds library.

Am I right?

Jettro
__________________
Jettro Coenradie
http://www.gridshore.nl

Last edited by jettro; Dec 23rd, 2008 at 04:01 AM.
Reply With Quote
  #2  
Old Dec 23rd, 2008, 04:01 PM
jeremyg484 jeremyg484 is online now
Senior Member
 
Join Date: Apr 2005
Location: San Francisco, CA
Posts: 816
Default

Quote:
Originally Posted by jettro View Post
However, I am having some problems at the client. There I cannot find the destinations.
What do you mean exactly? I'm assuming you mean when referencing the services at runtime with a RemoteObject?

It should definitely work without having to add
Code:
<destination id="remoteBookManager"/>
for the client.

Are you perhaps not accessing the destination by the correct identifier? The dynamic destination is configured such that by default the id is the same as the bean id of the exporter, though that is configurable via the serviceId property of the exporter.
__________________
Jeremy Grelle

Senior Software Engineer, Web Products Team
SpringSource
Reply With Quote
  #3  
Old Dec 23rd, 2008, 04:17 PM
jettro jettro is offline
Senior Member
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 150
Default

Yes I mean from code, I do create the services programmatically. I did manage to get it working with a custom build channelset. It seems the client does not know how to connect to the destination because the client does not know it.

Code:
public class BookService extends RemoteService {
        public function BookService(channelSet:ChannelSet) {
            super("bookService", "remoteBookManager",channelSet);
        }
}

public class RemoteService {
    protected var remoteObject:RemoteObject;

        public function RemoteService(id:String, destination:String, channelSet:ChannelSet) {
            this.remoteObject = new RemoteObject(id);
            this.remoteObject.destination = destination;
            this.remoteObject.channelSet = channelSet;
            this.remoteObject.addEventListener(FaultEvent.FAULT,onRemoteException);
        }
}
With the config file I cannot make this work.

I'll do some more experimentation to nail this one doen

Quote:
Originally Posted by jeremyg484 View Post
What do you mean exactly? I'm assuming you mean when referencing the services at runtime with a RemoteObject?

It should definitely work without having to add
Code:
<destination id="remoteBookManager"/>
for the client.

Are you perhaps not accessing the destination by the correct identifier? The dynamic destination is configured such that by default the id is the same as the bean id of the exporter, though that is configurable via the serviceId property of the exporter.
__________________
Jettro Coenradie
http://www.gridshore.nl
Reply With Quote
  #4  
Old Dec 23rd, 2008, 04:36 PM
jeremyg484 jeremyg484 is online now
Senior Member
 
Join Date: Apr 2005
Location: San Francisco, CA
Posts: 816
Default

Ahh, okay I see. Yes, I do think assigning the ChannelSet to the RemoteObject is the key there. I don't think there's any getting around that when using dynamic destinations.

See here:
http://livedocs.adobe.com/blazeds/1/...econfig_1.html

Though I believe if you have "my-amf" set up as an application-wide default, it would work without needing to explicitly specify the ChannelSet.

For example, from the services-config.xml in the BlazeDS sample:

Code:
<services>
        
        <service class="flex.samples.DatabaseCheckService" id="hsqldb" />
        
        <service-include file-path="remoting-config.xml" />
        <service-include file-path="proxy-config.xml" />
        <service-include file-path="messaging-config.xml" />
        
	    <service class="flex.samples.runtimeconfig.EmployeeRuntimeRemotingDestination" id="runtime-employee-ro" />

    	<!-- 
    	Application level default channels. Application level default channels are 
    	necessary when a dynamic destination is being used by a service component
    	and no ChannelSet has been defined for the service component. In that case,
    	application level default channels will be used to contact the destination.
        -->   
        <default-channels>
           <channel ref="my-amf"/>
        </default-channels>
    
</services>
__________________
Jeremy Grelle

Senior Software Engineer, Web Products Team
SpringSource
Reply With Quote
  #5  
Old Jan 1st, 2009, 03:50 PM
k.v.ahuja k.v.ahuja is offline
Junior Member
 
Join Date: Jan 2009
Posts: 6
Default

I have a similar issue here. I have configured the server as suggested. But, when i make a call from the client i get the following error:

Code:
message='Destination 'loginService' either does not exist or the destination has no channels defined

remoting-service

Code:
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" 
    class="flex.messaging.services.RemotingService">

    <adapters>
        <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
    </adapters>

    <default-channels>
        <channel ref="my-amf"/>
    </default-channels>

</service>

services-config.xml
Code:
    <channels>
        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
            <endpoint url="http : / / {server.name}:{server.port}/{context.root}/spring/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>

Spring beans
Code:
	<bean id="loginServiceController" class="org.phoenix.core.LoginService" />
	    

	<bean id="loginService" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
		<property name="service" ref="loginServiceController"/>
		<property name="messageBroker" ref="messageBrokerFactory"/>
	</bean>
What am i missing?
Reply With Quote
  #6  
Old Jan 2nd, 2009, 09:17 AM
pHk pHk is offline
Junior Member
 
Join Date: Dec 2008
Posts: 9
Default

Not sure whether they're typos or not, but it's supposed to be remoting-config.xml (not remoting-service) and there are some spaces in the endpoint URL in the services-config.xml which may cause some unexpected behaviour.
Reply With Quote
  #7  
Old Jan 3rd, 2009, 02:45 AM
k.v.ahuja k.v.ahuja is offline
Junior Member
 
Join Date: Jan 2009
Posts: 6
Default

Quote:
Not sure whether they're typos or not, but it's supposed to be remoting-config.xml (not remoting-service)
The remoting-service is defined in the Services-config file. The only thing that you have to worry about is to ensure that file name matches the one provided in services-config.xml

Quote:
some spaces in endpoint URL
- I did this because i was not allowed to post URL possibly because of being a new user.
Reply With Quote
  #8  
Old Jan 5th, 2009, 05:41 AM
jettro jettro is offline
Senior Member
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 150
Default Somebody wants to try it out?

I have a sample that I have been using for a while and I have re-written it with the blazeds spring integration. I still have the same problem as mentioned in this thread. It only works when I add an empty destination to the client side configuration. If someone has the time to try it out:

http://code.google.com/p/gridshore/s...books-overview

It is all maven, so you can build it using maven, do make sure you have the M1 of the integration in you repository.

You can start the application using jetty integrated with maven:
cd books-web
mvn clean jetty:run-war

Open the link
http://localhost:8080:/books-web
__________________
Jettro Coenradie
http://www.gridshore.nl
Reply With Quote
  #9  
Old Jan 5th, 2009, 05:57 AM
k.v.ahuja k.v.ahuja is offline
Junior Member
 
Join Date: Jan 2009
Posts: 6
Default

While i try the application...!!


Quote:
Originally Posted by jettro View Post
It only works when I add an empty destination to the client side configuration.
I am surprised that this works for you, because when I compile my application with an entry in remoting-service, I get an error on my web server, which says that I have the service exposed twice one in remoting-service and other in the spring-bean configuration.

However, I tried by creating a channel in my code-behind and assigned that channel to my remote service. It worked.
Reply With Quote
  #10  
Old Jan 5th, 2009, 07:17 AM
jettro jettro is offline
Senior Member
 
Join Date: Aug 2004
Location: The Netherlands
Posts: 150
Default

Quote:
Originally Posted by k.v.ahuja View Post
While i try the application...!!


I am surprised that this works for you, because when I compile my application with an entry in remoting-service, I get an error on my web server, which says that I have the service exposed twice one in remoting-service and other in the spring-bean configuration.

However, I tried by creating a channel in my code-behind and assigned that channel to my remote service. It worked.
I only added the destination to the client, so I duplicated the files. Yes I know that is not clean, but for the time being it does work. As for the Channels in code, yes I did that as well and for me it worked also. I am planning on using the other spring-flex module. The action script integration. There was some example code for configuring a channel using the xml config.
__________________
Jettro Coenradie
http://www.gridshore.nl
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:11 AM.


Contegix provides first-class managed hosting and partial sponsorship of these forums.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.