1.web.xml need to hava servlet mapping for servlet engine
[
]
2.services-config.xml need to have initalized with services + defauld channel + other regular values
[
server="Tomcat" />
class="mx.messaging.channels.AMFChannel">
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
class="mx.messaging.channels.SecureAMFChannel">
url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure"
class="flex.messaging.endpoints.SecureAMFEndpoint" />
class="mx.messaging.channels.AMFChannel">
url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling"
class="flex.messaging.endpoints.AMFEndpoint" />
class="mx.messaging.channels.HTTPChannel">
url="http://{server.name}:{server.port}/{context.root}/messagebroker/http"
class="flex.messaging.endpoints.HTTPEndpoint" />
class="mx.messaging.channels.SecureHTTPChannel">
url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure"
class="flex.messaging.endpoints.SecureHTTPEndpoint" />
]
3.remoting-config.xml need to have defined adaptors + distinations +
[
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" />
class="flex.messaging.services.messaging.adapters.JMSAdapter" />
hello.Hello
]
4.Define the remote object at the action script/application .mxml file
5. Define result handler and fault handler methods
[ private function faultHandler(fault:FaultEvent):void {
result_text.text = "code:\n" + fault.fault.faultCode + "\n\nMessage:\n" + fault.fault.faultString + "\n\nDetail:\n" + fault.fault.faultDetail;
}
private function resultHandler(evt:ResultEvent):void {
var hh:valueObjects.RemoteObject = (valueObjects.RemoteObject)(evt.message.body);
//result_text.text = evt.message.body.toString();
result_text.text = hh.address;
result_text.text += "\n" + hh.id;
result_text.text += "\n" +hh.name;
}
]
6.Invoke functions from a user custom event object
package hello;
public class Hello {
RemoteObject rm ;
public RemoteObject sayHello() {
return this.rm;
}
public void saveHello(RemoteObject rmOb) {
this.rm = rmOb;
}
public Hello() {
rm = new RemoteObject();
rm.setId(56);
rm.setAddress("79-A");
rm.setName("chand");
}
}
package hello;
import java.io.Serializable;
public class RemoteObject implements Serializable {
private static final long serialVersionUID = 4355646632118270964L;
private int id = 0;
private String name = "";
private String address = "";
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}