Expand my Community achievements bar.

RemoteObject Destination configuration problem

Avatar

Level 1
Hi,



I have created a very simple 2 state mxml file(attached
below) where you submit a name which is passed to a RemoteObject
which appends "Welcome " to the input string & returns the
whole string back.



The java class which does this is,



package samples.SimpleRemoteObject;

public class Echo {



public Echo(){

}

public String getString(String str){

return "Welcome " + str ;

}

}



I have added the following to flex-remoting-service.xml under

c:\tomcat\webapps\flex\WEB-INF\flex,



<destination id="EchoString">

<properties>

<source>samples.SimpleRemoteObject.Echo</source>

</properties>

</destination>



The <default-channels> & <adapters>
definition was already there.



I also put Echo.class under
C:\tomcat\webapps\flex\WEB-INF\classes\samples\SimpleRemoteObject.



After Tomcat(v5.5.9) is started, it correctly loads the
initial page

at
http://localhost:8080/flex/SimpleRemoteObject/SimpleRemoteObject.html

but after I click on submit, I always get "Error: Unknown
destination 'EchoString'". I have tried renaming the destination
names but there is no change in behavior.



Please let me know what am I doing wrong. All the samples are
running fine

though. This is my first attempt on doing something with
Flex.



Thanks,

Aejaz







<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns="*" layout="absolute">

<mx:Script>

<![CDATA[

import mx.rpc.events.*;

import mx.collections.*;

import mx.controls.*



private function getNameHandler(event:ResultEvent):void

{

Result.text = event.result.toString();

currentState='TargetState';

}



private function faultHandler(event:FaultEvent):void

{

Alert.show(event.fault.faultstring, "Error");

}

]]>

</mx:Script>

<mx:states>

<mx:State name="TargetState">

<mx:RemoveChild child="{button1}"/>

<mx:RemoveChild child="{formInput}"/>

<mx:RemoveChild child="{label1}"/>

<mx:AddChild position="lastChild">

<mx:Label x="99" y="130" width="265" height="28"
id="Result"/>

</mx:AddChild>

</mx:State>

</mx:states>



<mx:RemoteObject id="SendStringBack"
destination="EchoString" showBusyCursor="true"
fault="faultHandler(event)">

<mx:method name="getString"
result="getNameHandler(event)">

<mx:arguments>

<str>

{formInput.text}

</str>

</mx:arguments>

</mx:method>

</mx:RemoteObject>

<mx:TextInput x="119" y="129" id="formInput"/>

<mx:Button x="119" y="170" label="Submit" fontSize="13"
id="button1" click="SendStringBack.getString.send()"/>

<mx:Label x="119" y="86" text="What is your name ?"
width="160" fontSize="15" id="label1"/>

</mx:Application>


Text
7 Replies

Avatar

Level 2
Did you add the compiler argument?



-services
c:\tomcat\webapps\flex\WEB-INF\flex\flex-remoting-service.xml



under Project -> Properties -> Flex Compiler

Avatar

Level 1
Thanks for your reply. The value present in the "Additional
compiler arguments" field is,



-services
"C:\tomcat\webapps\flex\WEB-INF\flex\flex-enterprise-services.xml"



when I change it to,



-services
"C:\tomcat\webapps\flex\WEB-INF\flex\flex-remoting-service.xml"



I start getting,



exception 'java.lang.RuntimeException' while setting variable
'compiler.services'. It seems that the only value allowed is


"C:\tomcat\webapps\flex\WEB-INF\flex\flex-enterprise-services.xml".
I tried putting,



"C:\tomcat\webapps\flex\WEB-INF\flex\flex-enterprise-services.xml;C:\tomcat\webapps\flex\WEB-INF\flex\flex-remoting-service.xml"



it gave me "Unable to open
C:\tomcat\webapps\flex\WEB-INF\flex\flex-enterprise-services.xml;C:\tomcat\webapps\flex\WEB-INF\flex\flex-remoting-service.xml



Please let me know what does setting,



-services
"C:\tomcat\webapps\flex\WEB-INF\flex\flex-remoting-service.xml"



do & can't it be done manually.



Thanks,

Aejaz

Avatar

Level 2
You'll get that exception if the services xml file is not
formatted properly. The current parser is not very stable I guess.
I think you should modify the original flex-enterprise-services.xml
file to include your new destination and use that for the
compiler.

Avatar

Level 2
The -services option should always point to the top level
configuration file which is flex-enterprise-services.xml.



-services
"C:\tomcat\webapps\flex\WEB-INF\flex\flex-enterprise-services.xml"



If you open up flex-enterprise-services.xml, you'll see that
you can point to additional configuration files using the
'service-include' xml tag. In the case of the default application,
this already includes flex-remoting-service.xml.
flex-remoting-service.xml is only a subset of the configuration
information required by the compiler and cannot be used
separately.

Avatar

Level 1
has this issue been resolved? ...... I am having a similar
problem, but am getting the following error:



Channel.Connect.Failed error NetConnection.Call.Failed: HTTP:
Status 404



Because the uri for the RO destination channel (my-amf) is
parsing without the context.root:




http://localhost:8000//messagebroker/amf



perhaps you are having a similar problem. Please let me know,
thanks.

Avatar

Level 2
> Because the uri for the RO destination channel (my-amf)
is parsing without the context.root:



>
http://localhost:8000//messagebroker/amf



If you're compiling from the command-line, be sure that you
specify the context root using -context.root /samples.

This may also be configured in flex-config.xml, if using.

Avatar

Level 1
Hi,



I meet the same problem. But if i publish my project undex
samples webapps it works.

So i compared both webapp (/flex and /samples) the major
difference is in flex-enterprise-service.xml.

I set <security-constraint> in comment and...it works



Wish it can help you



Best regards



Eric