0
我正在構建一個使用Flex 4 + Spring Blazeds Integration 1.5 + Spring 3.0.5 + Hibernate在jboss-5.1.0.GA上運行的應用程序。我創建了一個簡單的登錄表單,當通過遠程對象提交一個字符串時,它工作正常。但是當嘗試使用Object時,它的簡單功能不起作用。有趣的是,它甚至不顯示警報,放了!另外,如果我刪除標籤「RemoteClass」它發送到Java但發生錯誤。貝婁是代碼和配置。遠程對象flex不工作
我的java類:
package com.controlefinanceiro.entities;
// imports
@Entity
@Table(name="CF_USER_SISTEMA")
public class UserSistema implements Serializable{
private static final long serialVersionUID = 1L;
@Id
@Column(name="USERNAME")
private String username;
@Column(name="PASSWORD")
private String password;
/**
* Constructor
*/
public UserSistema(){
}
// all getters and setters
}
我的Flex類:
package com.controlefinanceiro.view.model
{
[Bindable]
[RemoteClass=(alias="com.controlefinanceiro.entities.UserSistema")]
public class UserSistema
{
public var username:String;
public var password:String;
}
}
服務,配置:
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
</services>
<!-- Spring factory registration -->
<factories>
<factory id="spring"
class="com.controlefinanceiro.controller.SpringFactory" />
</factories>
<channels>
<channel-definition id="channel-amf"
class="mx.messaging.channels.AMFChannel">
<endpoint
url="http://localhost:8080/ControleFinanceiroServices/messagebroker/amf"
class="flex.messaging.endpoints.AMFEndpoint" />
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel-definition>
</channels>
// rest of config (log, redeploy)
</services-config>
遠程-配置:
<adapters>
<adapter-definition id="java-object"
class="flex.messaging.services.remoting.adapters.JavaAdapter"
default="true" />
</adapters>
<default-channels>
<channel ref="channel-amf" />
</default-channels>
<destination id="loginService">
<properties>
<factory>spring</factory>
<source>loginService</source>
</properties>
</destination>
</service>
Flex應用程序:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comp="com.controlefinanceiro.view.componentes.*">
<s:layout><s:BasicLayout/></s:layout>
<fx:Declarations>
<s:RemoteObject id="ro" destination="loginService" showBusyCursor="true" fault="onRemoteFault(event)"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
public function doLogin(event:MouseEvent):void{
Alert.show("login");
var usu:UserSistema = new UserSistema();
Alert.show("user");
//usu.username = user.text;
//usu.password = senha.text;
//ro.doLogin.addEventListener(ResultEvent.RESULT,onLoginSuccess);
//ro.doLogin.addEventListener(FaultEvent.FAULT,onLoginFault);
//ro.doLogin(usu);
}
public function doEcho(event:MouseEvent):void{
Alert.show("echo");
ro.echo.addEventListener(ResultEvent.RESULT,alertResult);
ro.echo.addEventListener(FaultEvent.FAULT,onLoginFault);
ro.echo(user.text);
}
// others methods that just do an Alert.show()
]]>
</fx:Script>
<mx:Canvas width="242" height="141" horizontalCenter="0" verticalCenter="0">
<s:Label id="msg" x="10" y="6"/>
<s:Label x="21" y="37" text="Usuario:"/>
<s:TextInput id="user" width="134" x="77" y="27"/>
<s:Label x="30" y="67" text="Senha:"/>
<s:TextInput id="senha" width="133" displayAsPassword="true" x="78" y="57"/>
<s:Button label="Login" click="doLogin(event)" id="login" x="165" y="100"/>
<s:Button x="113" y="100" label="Echo" click="doEcho(event)"/>
</mx:Canvas>
</s:Application>
PS:遺憾的英語不好和 「葡萄牙」 字樣的代碼:P
謝謝! Andre
您的services-config有一個硬編碼的URL。您是否使用相同的URL(AKA Localhost?)提供SWF?您是否使用過ServiceCapture或Charles或Flash Builder網絡監視器等程序來驗證來回發送的內容? – JeffryHouser 2011-02-08 01:01:29