Flex Spring框架成BlazeDS

官网地址:http://www.springsource.org/spring-flex

下载资源包: spring-flex-1.5.2.RELEASE-dist.zip

 

1. 代码配置(spring的配置不作说明):

1)引入jar包:spring-flex-core-1.5.2.RELEASE.jar

2)web.xml配置:

<listener>
    <listener-class>flex.messaging.HttpFlexSession</listener-class>
</listener>
<servlet>
    <servlet-name>MessageBrokerServlet</servlet-name>
    <servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
    <init-param>
        <param-name>services.configuration.file</param-name>
        <param-value>/WEB-INF/flex/services-config.xml</param-value>
    </init-param>
    <load-on-startup>3</load-on-startup>
</servlet>

 2)services-config.xml如附件配置

 3)flex应用配置:

-services "**\WebContent\WEB-INF\flex\services-config.xml" -locale en_US

4)flex调用配置:

/**
 * 简化对同一远程代理方法的调用
 * @param service
 * @param method
 * @param args
 * @param resultHandler
 * @param faultHandler
 *
 */
public static function invokeRemoteObjectMethod(service:RemoteObject, method:String, args:Array, resultHandler:Function, faultHandler:Function=null):void
{
	var operation:AbstractOperation=service.getOperation(method) as AbstractOperation;
	var handler:Function=function(event:ResultEvent):void
	{
		operation.removeEventListener(ResultEvent.RESULT, handler);
		resultHandler(event);
	}
	operation.addEventListener(ResultEvent.RESULT, handler);

	if (faultHandler != null)
	{
		var faultHandler:Function=function(event:FaultEvent):void
		{
			operation.removeEventListener(ResultEvent.RESULT, faultHandler);
			faultHandler(event);
		}

		operation.addEventListener(FaultEvent.FAULT, faultHandler);
	}

	operation.send.apply(service, args);
}

 

 

 

你可能感兴趣的:(blazeds)