Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1966680
  • 博文数量: 606
  • 博客积分: 9991
  • 博客等级: 中将
  • 技术积分: 5725
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-17 19:07
文章分类

全部博文(606)

文章存档

2011年(10)

2010年(67)

2009年(155)

2008年(386)

分类:

2009-04-21 19:52:55

使用自己发布的WebService与Flex通信
wsdl:
 
xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="" xmlns:soapenc12="" xmlns:tns="" xmlns:wsdl="" xmlns:xsd="" xmlns:soap11="" xmlns:wsdlsoap="soap/" xmlns:soapenc11="" xmlns:soap12="">
+ <wsdl:types>
- <xsd:schema xmlns:xsd="" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="">
- <xsd:element name="getKey">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
  <xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
  xsd:sequence>
  xsd:complexType>
  xsd:element>
- <xsd:element name="getKeyResponse">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string" />
  xsd:sequence>
  xsd:complexType>
  xsd:element>
- <xsd:element name="login">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string" />
  <xsd:element maxOccurs="1" minOccurs="1" name="in1" nillable="true" type="xsd:string" />
  xsd:sequence>
  xsd:complexType>
  xsd:element>
- <xsd:element name="loginResponse">
- <xsd:complexType>
- <xsd:sequence>
  <xsd:element maxOccurs="1" minOccurs="1" name="out" type="xsd:boolean" />
  xsd:sequence>
  xsd:complexType>
  xsd:element>
  xsd:schema>
  wsdl:types>
- <wsdl:message name="getKeyResponse">
  <wsdl:part name="parameters" element="tns:getKeyResponse" />
  wsdl:message>
- <wsdl:message name="getKeyRequest">
  <wsdl:part name="parameters" element="tns:getKey" />
  wsdl:message>
- <wsdl:message name="loginResponse">
  <wsdl:part name="parameters" element="tns:loginResponse" />
  wsdl:message>
- <wsdl:message name="loginRequest">
  <wsdl:part name="parameters" element="tns:login" />
  wsdl:message>
- <wsdl:portType name="UserServicePortType">
- <wsdl:operation name="getKey">
  <wsdl:input name="getKeyRequest" message="tns:getKeyRequest" />
  <wsdl:output name="getKeyResponse" message="tns:getKeyResponse" />
  wsdl:operation>
- <wsdl:operation name="login">
  <wsdl:input name="loginRequest" message="tns:loginRequest" />
  <wsdl:output name="loginResponse" message="tns:loginResponse" />
  wsdl:operation>
  wsdl:portType>
- <wsdl:binding name="UserServiceHttpBinding" type="tns:UserServicePortType">
  <wsdlsoap:binding style="document" transport="" />
- <wsdl:operation name="getKey">
  <wsdlsoap:operation soapAction="" />
- <wsdl:input name="getKeyRequest">
  <wsdlsoap:body use="literal" />
  wsdl:input>
- <wsdl:output name="getKeyResponse">
  <wsdlsoap:body use="literal" />
  wsdl:output>
  wsdl:operation>
- <wsdl:operation name="login">
  <wsdlsoap:operation soapAction="" />
- <wsdl:input name="loginRequest">
  <wsdlsoap:body use="literal" />
  wsdl:input>
- <wsdl:output name="loginResponse">
  <wsdlsoap:body use="literal" />
  wsdl:output>
  wsdl:operation>
  wsdl:binding>
- <wsdl:service name="UserService">
- <wsdl:port name="UserServiceHttpPort" binding="tns:UserServiceHttpBinding">
  <wsdlsoap:address location="" />
  wsdl:port>
  wsdl:service>
  wsdl:definitions>
 
===============================================================================
 
GetKeyFromXFire.mxml
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">
   
                    import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.utils.ObjectUtil;
            private var startTime:int;
            private var endTime:int;
            private function button_click():void {
    //执行webservice的getKey(String in0, String in1)操作
                webService.getKey('fisher','123456');
                startTime = getTimer();
                lbl.text = "";
            }
            private function getKeys_result(evt:ResultEvent):void {
    //将getKey(String in0, String in1)结果赋予textArea
                textArea.text = ObjectUtil.toString(evt.result);
                calcTime();
            }
            private function getKeys_fault(evt:FaultEvent):void {
                Alert.show(evt.type);
                calcTime();
            }
            private function calcTime():void {
                endTime = getTimer();
                lbl.text = "total time: " + (endTime - startTime) + "ms";
            }
        ]]>
   
 
                wsdl="">
  
                        resultFormat="object"
                result="getKeys_result(event);"
                fault="getKeys_fault(event);" />
   
   
                        label="get key from web service"
                click="button_click();" />
       
       
   
                editable="false"
            width="100%"
            height="100%" />
阅读(1936) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~