首先建立名为HelloWord的Web Service Project的项目,在新建过程中会自动导入XFire1.2 Core Libraries ;
项目建立成功后,右击项目新建一个web service(可以在Other中找到),过程中选择Create new Java bean,web service name 可以自己填写,(我添的是HelloWorldService),java package 可以自己填写,(我填写的是service);
deploy 项目,然回打开tomcat,webservice就建立好了。
接下来就是flex调用webservice的事了:
flex建立项目webservice,在webservice.mxml中输入如下代码:
|
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:WebService id="HelloWorld" wsdl="http://localhost:8080/HelloWorld/services/HelloWorldService?WSDL" useProxy="false"> <mx:operation name="example"> <mx:request> <in0>{input.text}</in0> </mx:request> </mx:operation> </mx:WebService> <mx:Panel id="panel" x="10" y="10" width="475" height="400" layout="absolute" title="Most Popular Posts"> <mx:TextInput x="194" y="20" id="input"/> <mx:Button x="169.5" y="60" label="连接WebService" id="btn" click="HelloWorld.example.send()"/> <mx:Text x="169.5" y="106" text="{HelloWorld.example.lastResult}" id="txt"/> </mx:Panel> </mx:Application>
|