??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区三区视频播放,4480yy私人影院高清不卡,草草影院在线观看http://www.aygfsteel.com/mstar/category/1720.html搞Y件开发就像被强奸,如果不能反抗,׃n受它吧!zh-cnSat, 02 Jun 2007 03:13:06 GMTSat, 02 Jun 2007 03:13:06 GMT60Flex~程模型--转脓(chung)http://www.aygfsteel.com/mstar/archive/2007/05/31/121154.html黑灵黑灵Thu, 31 May 2007 06:16:00 GMThttp://www.aygfsteel.com/mstar/archive/2007/05/31/121154.htmlhttp://www.aygfsteel.com/mstar/comments/121154.htmlhttp://www.aygfsteel.com/mstar/archive/2007/05/31/121154.html#Feedback0http://www.aygfsteel.com/mstar/comments/commentRss/121154.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/121154.html
转脓(chung)?http://blog.csdn.net/mylxiaoyi/archive/2007/05/16/1611579.aspx
Flex包含FlexcdQMXML以及(qing)ActionScriptE序语言Q如下表所C:(x)

包含在Flex中,但是却ƈ没有在上图中昄的还有Flex~译以及(qing)Flex调试器?br />我们使用MXML与ActionScript的组合来~写FlexE序。MXML和ActionScriptE序语言都给了我们访问Flexcd的能力。用MXML来定义程序的用户界面元素Q用ActionScript来定义客户逻辑与过E控制?br />Flexcd包含FlexlgQ管理器与行为。用基于组件的Flex开发模型,开发者可以合q~译的组Ӟ创徏新的lgQ或者是l合预编译的lg为复合组件?/div>

Flexcd与MXML和ActionScript的关p?/strong>
Flex是作为ActionScriptcd来实现的。这个类库包含组Ӟ容器与控ӞQ管理类Q数据服务类以及(qing)其他Ҏ(gu)的cR我们用MXML和ActionScript语言配合cd来开发程序?br />MXML 标签与ActionScriptcL是类的属性相对应。Flex分析MXML标签Qƈ且编译包含相应ActionScript对象的SWF文g。例如, Flex提供了ActionScript ButtoncL定义Flex按钮控g。在MXML中,我们可以用下面的MXML语句来创Z个按钮控Ӟ(x)
<mx:Button label="Submit"/>
当我们用MXML标签声明了一个控Ӟ我们创Z那个cȝ一个实例。这个MXML语句创徏了一个按钮对象,q且初始化这个按钮对象的label属性ؓ(f)Submit字符丌Ӏ?br />与ActionScript cȝ对应的MXML使用与ActionScriptcȝ同的命名U定。类名以一个大写字母开_(d)而且在类名中以大写字母分隔单词。每一个MXML标签属? 对应着ActionScript对象的一个属性,适合于对象的一U风|或者是q个对象的一个事件监听器?/div>

布局我们的程?/strong>
我们使用代表用户界面的组件来声明FlexE序的用L(fng)面。有两种cd的组Ӟ(x)控g与容器。控件是H体元素Q如按钮Q文本框Q列表框。容器是屏幕上包含控件和其他容器的矩形区域?br />在Flex的根部是单一的容器,UC为程序容器,q代表整个Flash播放器的界面。这个程序容器保存所有的其他的代表对话框Q面板和H体的容器?br />一个容器有预定义的规则来布局他的孩子容器和控Ӟ包括寸以及(qing)位置。Flex定义了布局规则来简化富|络E序的设计与实现Q然而也提供了够的灉|性来使得我们可以创徏多样的程序集合?br />使用预定义的布局规则的一个优点就是我们的用户可以很快的习(fn)惯我们的E序。也是_(d)通过标准化用户交互的规则Q我们的用户׃需要考虑如何来导航程序,相反却可以集中于E序所提供的内宏V?br />? 一个优点就是我们不必在定义D以及(qing)作ؓ(f)设计一部分的布局规则上花费大量的旉。相反,我们可以集中_֊于我们想要传递的信息以及(qing)我们要提供给用户的? 择,q且不需为所有用戯为的l节与程序响应担心。通过q样的方式,Flex提供了一个结构可以让我们快速容易的使用丰富的特性与交互集合来开发程序?/div>

使用Flex Builder来布局我们的程?/strong>
? 们可以用Flex Builder构徏FlexE序的用L(fng)面。我们可以用Flex Builder通过可视的编码与设计工具来开发Flex与ActionScriptE序。我们也可以使用可以提供代码提示与代码辅助特性的~辑~写 MXMLQActionScript与CSS代码Q从而帮助我们的开发工作?br />在这个编辑器中,我们可以切换到设计模式来可视化的开发我们的E序Q在设计d上用容器与lgQ用约束来布局我们的组Ӟq查看运行时用户界面的{化。然后我们用定制的~译器来构徏我们的工E,q且使用集成的调试工h调试我们的工E?/div>

在MXML中定义用L(fng)?/strong>
我们的程序可以由一个或是多个MXML文gl成。用多个MXML文g可以促进代码重用Q简化构建复杂程序的q程Qƈ且得多个开发者A(ch)献同一个工E变得更为容易?br />下面的例子是一个MXMLE序Q这个程序用一个按钮控件来触发从一个文本输入控件拷贝文本到一个文本区控gQ?br />
<?xml version="1.0" encoding="utf-8"?>
<!-- ?xml tag must start in line 1 column 1 -->
<!-- MXML root element tag. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
<!-- Flex controls exist in a container. Define a Panel container. -->
    
<mx:Panel title="My Application">
        
<!-- TextInput control for user input. -->
        
<mx:TextInput id="myInput" width="150" text=""/>
        
<!-- Output TextArea control. -->
        
<mx:TextArea id="myText" text="" width="150"/>
        
<!-- Button control that triggers the copy. -->
        
<mx:Button id="myButton" label="Copy Text"/>
           
    
</mx:Panel>
</mx:Application>


q个E序W一行指明了XML声明Q而且必须攑֜MXML文g的第一行,W一列?br />W二行以<mx:Application>标签开始,q是FlexE序的根元素。这个标{֌含了Flex名字I间声明。在起始与结束的<mx:Application>标签之间的部分定义了FlexE序?br />下图演示了在Flash播放器中q行q个E序的效果图Q?/div>

正如q段代码所写的Q这个例子布局了我们的用户界面Q但是却q没有包含从文本输入框控件到文本区控件的拯逻辑?/div>

向FlexE序中添加ActionScript
我们可以Z下列目的使用ActionScript
处理事g Flex用户界面是事仉动的。例如,当用户选择一个按钮时Q这个按钮生成一个事件。我们在ActionScript中定义名Z件监听器的函数来处理事g。我们的事g监听器可以打开一个窗口,播放SWF文gQ或者是执行我们的程序所必须的Q何动作?br />处理错误 我们在ActionScript处理q行旉误。我们可以检数据验证错误,向用户发送错误信息,向服务器重新提交hQ或者是执行Z我们E序的其他事件?br />在MXML语句中向Flex控gl定数据对象 我们可以使用数据l定从一个Flex控gl织数据模型Q或是从数据模型l织lgQ或者是从一个组件向另一个组件拷贝数据?br />定义自定义组?我们可以从Flexlgcdơ承来创徏适合我们E序需求的lg?br />下面的例子是在前一个例子的基础上所做的更改Qؓ(f)按钮的click事gd事g监听器。一个事件监听器Z响应用户的事件而执行的ActionScript代码。在我们q个例子中的事g监听器是当用户选择按钮控g时从文本输入控g向文本区拯文本Q?br />
<?xml version="1.0" encoding="utf-8"?>
<!-- ?xml tag must start in line 1 column 1 -->
<!-- MXML root element tag. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
<!-- Flex controls exist in a container. Define a Panel container. -->
    
<mx:Panel title="My Application">
        
<!-- TextInput control for user input. -->
        
<mx:TextInput id="myInput" width="150" text=""/>
        
<!-- Output TextArea control. -->
        
<mx:TextArea id="myText" text="" width="150"/>
        
<!-- Button control that triggers the copy. -->
        
<mx:Button id="myButton" label="Copy Text"
            click
="myText.text=myInput.text;"/>
           
    
</mx:Panel>
</mx:Application>

? 一个例子在MXML代码中直接插入了ActionScript代码。虽然这对于一或是两行的ActionScript代码可以工作的很好,但是对于更ؓ(f)? 杂的逻辑Q通常我们?x)?lt;mx:Script>块中定义我们的ActionScriptQ如下面的例子所C:(x)
<?xml version="1.0" encoding="utf-8"?>
<!-- ?xml tag must start in line 1 column 1 -->
<!-- MXML root element tag -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
<mx:Script>
        
<![CDATA[
           
            // Define an ActionScript function.
            private function duplicate():void {
                myText.text=myInput.text;
            }
        
]]>
    
</mx:Script>
    
<!-- Flex controls exist in a container. Define a Panel container. -->
    
<mx:Panel title="My Application">
        
<!-- TextInput control for user input. -->
        
<mx:TextInput id="myInput" width="150" text=""/>
        
<!-- Output TextArea control. -->
        
<mx:TextArea id="myText" text="" width="150"/>
        
<!-- Button control that triggers the copy. -->
        
<mx:Button id="myButton" label="Copy Text"
            click
="duplicate();"/>
           
    
</mx:Panel>
</mx:Application>

? q个例子中,我们使事件监听器作ؓ(f)一个ActionScript函数来实现。FlexZ响应用户选择按钮控g调用q个函数。这U技术得我们可以将我们 的MXML代码从我们的ActionScript代码中分d来。ؓ(f)了增加程序的模块性我们也可以选择我们的E序分ؓ(f)多个文g?/div>

使用数据l定
FlexZlg之间属性的l定Q或是到数据模型的绑定提供了单的语法。在下面q个例子中,花括号中的值将文本区的text属性绑定到了文本输入控件的text属性。当用户在文本输入控件中输入文本Ӟ他会(x)自动的拷贝到文本区控Ӟ如下面的例子所C:(x)
<?xml version="1.0" encoding="utf-8"?>
<!-- ?xml tag must start in line 1 column 1 -->
<!-- MXML root element tag. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    
<!-- Flex controls exist in a container. Define a Panel container. -->
    
<mx:Panel title="My Application">
        
<!-- TextInput control for user input. -->
        
<mx:TextInput id="myInput" width="150" text=""/>
        
<!-- Output TextArea control. -->
        
<mx:TextArea id="myText" text="{myInput.text}" width="150"/>
    
</mx:Panel>
</mx:Application>

 
控制E序昄
Flex定义我们在程序中可以使用的默认显C,或者是修改来定义我们特定的昄。作ZҎ(gu)C的一部分Q我们可以修改下面的一些或是全部:(x)
一个组件或是程序的高度或是宽度。所有的lg都有一个默认的寸。我们可以用默认的寸Q指定我们自q寸Q或者作为布局我们E序的一部分让Flex重新调整一个组件的寸?br />格式 Ҏ(gu)集合,例如字体Q字P文本寚w属性,颜色。这与在层叠样式?CSS)定义与用的相同?br />皮肤 控制l合昄的符受皮肤化是通过修改或是替换他的可视化元素来改变一个组件显C的q程。这些元素可以图像,SWF文gQ或者是包含l画APIҎ(gu)的类文gl成?br />行ؓ(f) E序或是用户行ؓ(f)引v的对于一个Flexlg的可见的或是可听的变化。行为的例子如基于鼠标移动点ȝUd或是lg寸的重新调整?br />视图状?/strong> 在许多富|络E序中,界面的改变基于用h执行的Q务。视囄态可以让我们通过修改基内Ҏ(gu)变化一个组件的内容和显C或者是E序?br />转化 转化定义了视囄态的改变如何昄在屏q上。我们用特效类Q结合处理{化的昑ּ效果设计来定义{化?/div>

使用数据服务工作
Flex 被设计用来与可以讉K本地和远E服务端逻辑的服务进行交互。例如,一个FlexE序可以使用AMF来连接用简单对象访问协?SOAP)的网l服务,q? 回XML的HTTP URLQ或者是Flex数据服务Q与位于与Flex同一个程序服务器上的Java对象。MXML提供数据讉K的组件称之ؓ(f)数据服务lg。MXML包含下列 的一些数据服务组Ӟ(x)
WebService 提供到基于SOAP的网l服务的讉K?br />HTTPService 提供到返回数据的HTTP URL的访问?br />RemoteObject 提供C用AMF协议的Java对象的访问。这个选项只在Flex数据服务或是Macromedia ColdFusion MX 7.0.2中可用?br />? 我们的FlexE序中选择如何来访问数据媄响着我们E序的性能。因为FlexE序是在W一ơ请求之后缓存在览器中的,当程序运行时Q数据访问是影响E序 性能的主要原因。ؓ(f)了向用户传递数据Flex提供了几U解x案。他数据交l调用在Flexc\径中装入的Javacȝq行时服务,或者是向网l服务或 是HTTP服务器发送代理请求?br />使用WebServicelg允许我们使用ZSOAP的方法,但是他ƈ不L产生最优的性能。同Ӟ使用SOAP~码的额处XML需要比AMF所做的更多的内宏V?br />|络服务中的SOAP性能同时依赖于我们的|络服务的实现。不同的E序服务器用不同的|络服务后端Q所以我们会(x)看到依赖于不同实现的性能。理解我们的实现表现如何的唯一Ҏ(gu)是装入q测试我们的服务?br />在许多情况下Q我们的选择依赖于我们已存在的程序以?qing)我们如何选择他们集成到后台服务器资源中。网l服务的表现在很大程度上依赖于我们的E序服务器的|络服务引擎的底层实玎ͼ所以我们应装入q测试他们的性能?/div>

我们数据模型从我们的视图中分离
Z清楚的分ȝL(fng)面,E序相关的数据,数据服务Q我们可以用Flex数据模型来存储控制器与数据服务之间的数据。这U三层设计是输入数据与数据服务共同作用的l果?br />当我们计划一个程序,我们要决定程序必d储的数据cd以及(qing)q些数据要如何处理。这有助于我们决定我们需要什么类型的数据模型。例如,假设我们军_我们的程序必d储顾员的相关数据。一个简单的֑模型可能包含姓名Q部门以?qing)邮地址属性?br />一 个Flex数据模型是一个包含我们用来存储程序相x据的属性的ActionScript对象。我们可以将数据模型用于数据验证Q从而他可以包含客户端业 务逻辑。我们可以在MXML或是ActionScript中定义一个数据模型。在MVC设计模式中,数据模型代表模型层?br />我们可以在MXML? {,ActionScript函数或是ActionScriptcM定义数据模型。在MXML中编写的模型用利于快速开发与化数据存储,但是他不能提? M额外的功能,而我们不可以讑֮模型属性的数据cd。如果我们想要设定数据类型以?qing)?f)额外的功能提供方法,我们应用基于ActionScript? cR在通常情况下,我们应ؓ(f)了简化数据结构用基于MXML的模型,为更为复杂的l构以及(qing)客户端业务逻辑使用ActionScript?/div>
 


黑灵 2007-05-31 14:16 发表评论
]]>Flex+Webservice中文q问题解决http://www.aygfsteel.com/mstar/archive/2005/06/18/6341.html黑灵黑灵Sat, 18 Jun 2005 14:34:00 GMThttp://www.aygfsteel.com/mstar/archive/2005/06/18/6341.htmlhttp://www.aygfsteel.com/mstar/comments/6341.htmlhttp://www.aygfsteel.com/mstar/archive/2005/06/18/6341.html#Feedback0http://www.aygfsteel.com/mstar/comments/commentRss/6341.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/6341.html于是上网找资?l果没有扑ֈflex+webservice的,其他的如flex+rometeobject{等的倒是有。但是很多最l也没有说出合适的解决办法。很多h说要把encoding="utf-8"Ҏ(gu)GBK、GB2312{等Q但是都不奏效,相反原来直接写在component上的中文却成的ؕ码。于是我觉得Q问题不是出在客L(fng)Q应该是服务端。于是我惌v以前一些解决java中文q的问题。用l典的{换方法:(x)
//q是一个将西欧字符转换为gb2312字符的{换方?/SPAN>
public static final String getGBString(String src) 
    
try {
        
return new String(src.getBytes("ISO-8859-1"), "gb2312");
    }
 catch (java.io.UnsupportedEncodingException e) {
        
return null;
    }

}

在webservice的javac里面的所有中文返回以前都用这个函数{换一下?BR>OKQ问题解决了?BR>但是q没有完全解冻I因ؓ(f)你在所有返回中文的函数里都要有q个Ҏ(gu)?BR>我不知道Webservice的引擎有没有cLServlet的Filter的东ѝ以前在解决|页上中文ؕ码的时候只要写一个Filtercd转换p了?img src ="http://www.aygfsteel.com/mstar/aggbug/6341.html" width = "1" height = "1" />

黑灵 2005-06-18 22:34 发表评论
]]>
Using Flex Builder to Create Web Service–Based Flex Applicationshttp://www.aygfsteel.com/mstar/archive/2005/06/12/5990.html黑灵黑灵Sun, 12 Jun 2005 14:31:00 GMThttp://www.aygfsteel.com/mstar/archive/2005/06/12/5990.htmlhttp://www.aygfsteel.com/mstar/comments/5990.htmlhttp://www.aygfsteel.com/mstar/archive/2005/06/12/5990.html#Feedback0http://www.aygfsteel.com/mstar/comments/commentRss/5990.htmlhttp://www.aygfsteel.com/mstar/services/trackbacks/5990.html 

Adding Web Services

Flex Builder makes it easy to add named and unnamed web services to an application by exposing the Flex whitelist.

  1. Open the Data panel by selecting Window > Data (Ctrl + Shift + F7).
  2. To add a service, click the Plus (+) button in the Data panel and choose Web Service.
  3. In the pop-up menu, see all of the named and unnamed web services that have been configured in the Flex whitelist (Figure 1).

    The Data panel.

    Figure 1. The Data panel.

    The named service, SampleEmployeeWS, is one of the services displayed in the list. Named web services allow you to reference web services with simple names instead of using web service WSDL URLs. Entries in the flex-config.xml file map named web services to the web service details, such as the WSDL URL and the type of authentication. This means that web service references in your applications aren’t hard coded. You can also set up named services for HTTP services and Remote Objects.

  4. Select the named service SampleEmployeeWS from the Add WebService pop-up menu (Figure 2).
The Add WebService dialog box.

Figure 2. The Add WebService dialog box.

Note: In the pop-up menu, you might see entries that contain { } or * syntax. These indicate global filters. Consider these indicators as acceptable URL formats. For example http://{localserver}/* indicates any web service running on the local server, and is legal. For more information on whitelists, see Configuring the whitelist for Flex applications (TechNote 19251).

Once you have added the service to the application, the web service operations, operation parameters, and operation result objects display in the Data panel (Figure 3).

The Data panel with a web service.

Figure 3. The Data panel with a web service.

In the next sections you learn how to:

  • Create a binding to the web service operation parameters
  • Create a binding from the web service operation result to a component
  • Create an event that invokes the web service operation

Binding a Component to a Web Service Request

Use the following steps to bind the dept ComboBox to the getList operation’s parameter deptId.

  1. Select the pre-populated ComboBox in Design view.
  2. Open the Tag Inspector by selecting Window > Tag Inspector (F9) and selecting the Bindings tab.
  3. Click the Plus (+) button. This displays the Add Binding - Step 1 dialog box.

    In the Add Binding dialog box, you must select the binding direction and a property to bind to. The binding direction specifies how data will flow. Data can flow FROM the selected component (an out binding), or TO the selected component (an in binding). When you select a direction radio button, the default property for the direction displays in the selected component properties list. The selected component properties are a list of properties that are bindable for the selected component. The list of component properties changes depending upon the binding direction. When the direction is TO (or in), the write and read/write properties of the selected component display. When the direction is FROM (or out), the read and read/write properties of the selected component display.

    For this binding, data needs to flow from a ComboBox property to the web service operation’s argument. Select the radio button to the left of “Data will flow FROM ‘dept?. The selectedItem is the default property of the ComboBox, so it is selected by default in the list of properties; it also displays in the Binding Source field at the bottom of the dialog box. The selectedItem property of the ComboBox is an object composed of a data and a label. In this case, you must bind to the data field. Type .data at the end of the selectedItem property in the Binding source text field so that it is: selectedItem.data. Click Next.

    The Add Binding ?Step 1 dialog box with FROM selected.

    Figure 4. The Add Binding ?Step 1 dialog box with FROM selected.

  4. The second bindings dialog box appears. This dialog box contains a list of components that are in the MXML application and a list of component properties that can be bound TO or FROM.

    If you select FROM in the initial binding dialog box, the binding is TO the component property you select in the secondary dialog box. Data will flow from the component property you selected in the initial dialog to the component property you select in the second bindings dialog box.

    Conversely, if you select TO in the initial binding dialog box, then the binding is FROM the component property you select in the secondary dialog box. Data will flow to the component property you selected in the initial dialog box from the component property you select in the second binding's dialog box.

    When you select TO (or in) in the initial binding dialog box, the secondary dialog box’s component property list displays read and read/write properties. When the direction is FROM or out in the initial binding dialog box, the secondary dialog box’s component property list displays write and read/write properties.

    For this binding, data needs to flow to the web service operation’s deptId argument. Select the web service service1 in the “Data will flow TO ?tree on the left.

  5. Expand the getList operation and its request object in the “Selected component property?tree and select the deptId argument. The Binding destination displays service1.getList.request.deptId.

    The Add Binding ?Step 2 dialog displaying TO.

    Figure 5. The Add Binding ?Step 2 dialog box displaying TO.

  6. Click Finish. This creates the binding between the ComboBox and the web service operation argument. Look in Code view. See the generated code:

     <mx:WebService serviceName="SampleEmployeeWS" id="service1">
          <mx:operation name="getList">
            <mx:request>
              <deptId>{dept.selectedItem.data}</deptId>
            </mx:request>
          </mx:operation>
    </mx:WebService>
    

    In Code or Design view, when you select a component with a binding, the component icon, name (or type), and bindings display in the Bindings panel. Selecting the binding in the Bindings panel causes binding direction to display in the Direction field and the component property that the binding is TO or FROM to display the Bound to field. Double-click the binding to edit the full binding. Clicking the Bound to field makes the second binding dialog box appear so that you can edit it.

    When you select the ComboBox in Code or Design view, the selectedItem.data binding displays in the Bindings panel. Selecting the binding displays the direction as out and the Bound to field displays service1.getList.request.deptId. When you select the web service, service1, in the Data panel, getList.request.deptId displays in the Bindings panel. Selecting the binding displays the direction as in and the Bound to field displays dept.selectedItem.data.

    The Bindings panel when you select the ComboBox

    Figure 6. The Bindings panel when you select the ComboBox binding

    The Bindings panel when you select the web service

    Figure 7. The Bindings panel when you select the web service binding

Binding a Component To a Web Service Result

To display the result of your web service operation call, you must create a binding from the web service result to a component property. This is a similar process to the previous binding, but the direction is opposite. The data needs to flow to the component property from the web service operation result instead of from the component property to the web service operation request.

  1. Select the DataGrid component in Design view and click the Plus (+) button in the Bindings panel. This displays the Add Binding - Step 1 dialog box.
  2. The web service result data needs to flow to the DataGrid. Select the "Data will flow TO <mx:DataGrid>" radio button if it hasn't been selected. The default property, dataProvider, is selected in the Component property list.
  3. Notice that the binding syntax displays in the Binding Destination field at the bottom of the dialog box as dataProvider.
  4. Click Next to go to the second binding dialog box.

    The Add Binding ?Step 1 dialog with TO selected

    Figure 8. The Add Binding ?Step 1 dialog with TO selected.

  5. In the second bindings dialog box, select the web service service1 in the “Data will flow FROM…?tree.
  6. Expand the getList operation in the selected component property tree.
  7. Since the DataGrid dataProvider property expects an array, select the result:(Array) node under the getList operation. The Bindings source at the bottom of the dialog box displays service1.getList.result.

    The Add Binding ?Step 2 dialog displaying FROM.

    Figure 9. The Add Binding ?Step 2 dialog displaying FROM.

  8. Click Finish. The Binding icon now appears in Design view
  9. Go to Code view. Notice the added binding in the DataGrid’s dataProvider property:

    <mx:DataGrid widthFlex="1" dataProvider="{service1.getList.result}">
    
 

Using the Network Monitor To See SOAP Messages and ActionScript Objects

Now that you have set up the bindings and the trigger, it is time to test the application. The Network Monitor helps you debug Flex applications that use data services such as web services, Remote Objects, or HTTP. With the Network Monitor, you can examine the SOAP, AMF, Remote Object, XML, and HTTP traffic as it flows between the Flex application and the data service or services.

The Network Monitor also supports simple trace statements for basic application debugging. Network Monitor traces, such as the one below, display in the Network Monitor at runtime.

NetworkDebugger.NetworkMonitor.trace('trace text goes here');
  
  1. Select Window > Network Monitor (Ctrl + Alt + N) to open the Network Monitor.
  2. Select the Enable Flex Network Monitor checkbox to activate the Network Monitor.

    The Network Monitor in the enabled state.

    Figure 12. The Network Monitor in the enabled state.

  3. Choose File > Run (F6) or click the Run button on the toolbar to preview the application. As the application loads, see the entries appear in the Network Monitor.
  4. In testing this sample application, you aren’t interested in the HTTP traffic, so select the filter icon and deselect HTTP.

    Note: You do not lose the data when you deselect a filter, you only hide it. If you need the data, simply select the filter.

    The Network Monitor after selecting Run, with filtering button selected.

    Figure 13. The Network Monitor after selecting Run, with filtering button selected

    Because you have filtered out the HTTP traffic, you will see the following web service events:

    • First, the initialization of the web service where the web service WSDL is requested
    • Second, the WSDL that is received in response to the WSDL request
  5. Select Product Management in the ComboBox and click the Get Employee List Button to trigger the web service operation. Notice that a few SOAP and web service events appear.

    Selecting the first SOAP event displays the SOAP envelope sent to the web service in the details pane.

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <SOAP-ENV:Body xmlns:ns1="http://localhost:8400/samples/services/EmployeeWS">
          <ns1:getList SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <deptId xsi:type="xsd:string">PM</deptId>
          </ns1:getList>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    Selecting the first web service RPC event displays the SOAP envelope as represented in ActionScript.

    Method: getList

    Parameter 1:
    name : deptId
    type : string
    value : PM

    Selecting the second SOAP event displays the SOAP envelope received from the web service in response to the web service call.

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <SOAP-ENV:Body>
          <ns1:getListResponse xmlns:ns1="http://localhost:8300/samples/services/EmployeeWS" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
             <getListResult xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">
                <item href="#id0"/>
                <item href="#id1"/>
             </getListResult>
          </ns1:getListResponse>
          <multiRef xmlns:ns2="http://www.macromedia.com/samples" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" id="id0" SOAP-ENC:root="0" xsi:type="ns2:Employee">
             <name xsi:type="xsd:string">Ronnie Hodgman</name>
             <phone xsi:type="xsd:string">555-219-2030</phone>
             <email xsi:type="xsd:string">rhodgman@fictitious.com</email>
             <salary xsi:type="xsd:double">0.0</salary>
          </multiRef>
          <multiRef xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="http://www.macromedia.com/samples" id="id1" SOAP-ENC:root="0" xsi:type="ns3:Employee">
             <name xsi:type="xsd:string">Joanne Wall</name>
             <phone xsi:type="xsd:string">555-219-2012</phone>
             <email xsi:type="xsd:string">jwall@fictitious.com</email>
             <salary xsi:type="xsd:double">0.0</salary>
          </multiRef>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    Selecting the second web service RPC event displays the response to the web service call as represented in ActionScript.

    [array] : 
    length[Number] : 2
    [0][object] : 
    SOAP-ENC:root[String] : 0
    email[String] : rhodgman@fictitious.com
    id[String] : id0
    name[String] : Ronnie Hodgman
    phone[String] : 555-219-2030
    salary[Number] : 0
    xmlns:SOAP-ENC[String] : http://schemas.xmlsoap.org/soap/encoding/
    xmlns:ns2[String] : http://www.macromedia.com/samples
    xsi:type[String] : ns2:Employee
    
    [1][object] : 
    SOAP-ENC:root[String] : 0
    email[String] : jwall@fictitious.com
    id[String] : id1
    name[String] : Joanne Wall
    phone[String] : 555-219-2012
    salary[Number] : 0
    xmlns:SOAP-ENC[String] : http://schemas.xmlsoap.org/soap/encoding/
    xmlns:ns3[String] : http://www.macromedia.com/samples
    xsi:type[String] : ns3:Employee
    
    The Network Monitor after with the web service ActionScript object selected.

    Figure 14. The Network Monitor after with the web service ActionScript object selected.

Developing and debugging applications can be time consuming. As you have seen, with Flex Builder’s visual data binding you can quickly wire together simple Flex applications. The Network Monitor eases the process of debugging data services in Flex applications, making you more productive.



黑灵 2005-06-12 22:31 发表评论
]]>
վ֩ģ壺 ˮ| | Դ| | ɽ| µ| | | | | | | | | ͨ| Ҧ| ߮| | Ȫ| ƽ| ȫ| ̫| ɫ| | պ| | Ϻӿ| ƽ| ϳ| ̨| | | | | | ʯ| | ˮ| ƽ| | |