【ZZ】JAVA+FLEX 使用WEB SERVICE的集成

FDS+JAVA开发... 本人在学习FDS的时候,遇到N多问题,网上很少能找到之类资料...找到了也不是很全,所以今天我想把这个过程和一些概念写在这里...希望更多人学习的时候不会饶更多弯... 废话说到这里...首先要明白什么叫做FDS,它干了件什么事儿,,,,FDS全名:Flex data service现在FDS就是LCDS...FDS就是他的前身... 首先需要安装有FDS,如果安装的是 阅读详情

我个人一直以为使用PYTHON和FLEX通过PYAMF通信是BS RIA的王道,不过在JAVA加强了对webservice的支持之后,在我对JAVA不那么偏执之后,我觉得是不是有必要也来看一下JAVA 和FLEX的集成,不管怎么样,这篇文章转给大家

Building a CRUD application using Java 6 Web Services and Flash Builder 4

 

October 12, 2009 5:29 PM

Java SE 6 has built-in support for web services thanks to JAX-WS 2.0 . Armed with nothing more than JDK 6, you can easily publish or consume a web service. This makes it really easy for a developer to prototype and quickly get started with web services. Using the data-centric features in Flash Builder 4, a web service can be easily introspected and accessed. In this article, I will build an end-to-end simple CRUD application in Java and Flex 4, where the Java methods are exposed as web service operations.

Java 6 Goodness

On the java side, all you need for this article is JDK 6 and optionally the mysql connector JAR if you want to run the final application.

To look at the complete Java code, download BookService.java and Book.java . The sample uses a simple mysql table called Books:

CREATE
 TABLE
 Books

(
BOOK_ID SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
BOOK_NAME VARCHAR (400) NOT NULL ,
BOOK_PRICE FLOAT NOT NULL ,
BOOK_AUTHOR VARCHAR (400) NOT NULL ,
PRIMARY KEY (BOOK_ID)
);

INSERT INTO Books ( BOOK_NAME, BOOK_PRICE, BOOK_AUTHOR )
VALUES ( 'Midnight''s Children' , 250, 'Salman Rushdie' )
INSERT INTO Books ( BOOK_NAME, BOOK_PRICE, BOOK_AUTHOR )
VALUES ( 'Shame' , 225, 'Salman Rushdie' );
INSERT INTO Books ( BOOK_NAME, BOOK_PRICE, BOOK_AUTHOR )
VALUES ( 'To Kill a Mocking Bird' , 250, 'Harper Lee' );
INSERT INTO Books ( BOOK_NAME, BOOK_PRICE, BOOK_AUTHOR )
VALUES ( 'The Colour of Magic' , 250, 'Terry Pratchett' );

To expose your Java class as a web service, simply:

1) Annotate your Java class with @WebService, @WebMethod.

package
 com.sampl
e
;

import com .sample .Boo k ;
import javax .jws .WebServic e ;
import javax .jws .WebMetho d ;
import javax .jws .soap .SOAPBindin g ;
import javax .xml .ws .Endpoin t ;

@WebService
@SOAPBinding(style = SOAPBinding .Style .RPC)
public class BookService
{

@WebMethod
public int addBook(Book book )
{
/* insert book into db */
in t resultCode = 0;
Connectio n connection = null;
/* code omitted for brevity */

2) Use the Endpoint class in main()

   public
 static
 voi
d
 main
(String
[] args
)
{
// create and publish an endpoint
BookServic e bookservice = new BookService ();
Endpoin t endpoint = Endpoint.publish("http://localhost:8080/books" , bookservice);
}

3) Create a directory called generated and run apt (Annotation Processing Tool):

apt -cp .;mysql.jar -d generated com/sample/BookService.java

4) Run your class:

java -cp generated;mysql.jar com.sample.BookService

That's it, you have a web server running on localhost:8080 and you can access the WSDL by navigating to http://localhost:8080/books?wsdl

Flash Builder 4 Magic

Accessing the WSDL in Flash Builder 4 to build a Flex application is a snap.

1) Get Adobe Flash Builder 4 Beta 2 from Adobe Labs if you haven't already.

2) Create a new Flex Project, type in a project name and hit Finish.

3) In the bottom part of Flash Builder, choose the Data/Services tab and click on "Connect to Data/Service".

New Project Wizard

4) Pick Web Service, hit Next.

Connect to Data Service Wizard

5) Paste the WSDL URL http://localhost:8080/books?wsdl as the "WSDL URI" and hit Finish.

Connect to Data Service Wizard

6) Flash Builder 4 will introspect the WSDL and show you a list of operations you can select. Hit Finish.

Wiring it to a Flex UI

1) Start off by replacing your main MXML file with the following code:

<?xml
 version
="1.0"
 encoding
="utf-8"
?>
<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/halo"
minWidth ="1024" minHeight ="768" >
<s :Panel title ="Books" x ="61" y ="78" width ="124" height ="387" >
<s :List id ="list" x ="0" y ="10" width ="100%" height ="100%"
borderVisible ="false" ></s :List >
</s :Panel >
<s :Panel title ="Book Info" x ="193" y ="78" width ="379" height ="387" >
<mx :Form x ="0" y ="10" width ="377" height ="300" >
</mx :Form >
<s :HGroup x ="66" y ="309"
height ="46"
verticalAlign ="middle"
contentBackgroundColor ="#938F8F" >
<s :Button label ="Add" id ="button" />
<s :Button label ="Update" id ="button2" />
<s :Button label ="Delete" id ="button3" />
<s :Button label ="Get" id ="button4" />
</s :HGroup >
</s :Panel >
</s :Application >

You should now have a UI that looks this in design view:

Flash Builder 4

2) Switch to design view. Select the list in the "Books" panel. Right click the list and choose "Bind to Data".

Flash Builder 4

3) Choose "New service call" and select the operation as getBooks() . Choose "Bind to field" as name.

Flash Builder 4

4) Now select the form in the "Book Info" panel, right click it and choose "Bind to Data." Choose "Data type" in the "Generate form for" drop down. Hit Next.

Connect to Data Service Wizard

You can choose the ordering of values in the wizard.

Connect to Data Service Wizard

The generated form by default is bound to a value object with name "book."

5) Right click the list in the "Books" panel and choose "Generate Change Handler." The view will shift to source code and type in the following code into the change event handler:

/* 
point book to the selected item 
*/

book = list.selectedItem as Book ;

This is done so that every time the selected changes in the list, the form on the right is updated. If you run the application now, it should get the list of books from the server.

6) To make sure the first item in the list is selected every time the list is retrieved from the server, add a "result" event handler to the CallResponder that fetches the data in your main MXML file.

<s
:CallResponder
 id
="getBooksResult"
 result
="list.selectedIndex=0"
/>

CRUD

Getting the Add/Update/Delete/Get buttons to work is painless:

1) Select the Add button in design view.

2) Right click, choose "Generate Service Call" and choose the addBook operation.

3) The IDE automatically switches to source view so that you can type in the parameter to the addBook operation. Simply type in book

protected
 functio
n
 button_clickHandler
(event:MouseEvent
):void

{
addBookResult.token = books.addBook(book);
}
CRUD App with Java 6 Web Services and Flash Builder 4

4) Repeat steps 1 - 3 for the update and delete buttons. The delete button uses an integer parameter, book.bookid instead of book .

5) Right click the "Get" button and choose "Generate Click Handler." In the event handler, call the list's creation complete method.

protected
 functio
n
 button4_clickHandler
(event:MouseEvent
):void

{
list_creationCompleteHandler(null);
}

6) Optionally you could call list_creationCompleteHandler(null) after add, update and delete so that the list on the left is refreshed.

That's it, you have a CRUD app working! You can download the complete MXML file here.

CRUD App with Java 6 Web Services and Flash Builder 4

Conclusion

Web services are an easy medium to tap into for both Java and Flex developers. JDK 6 and Flash Builder comes with out-of-the-box support for it and you can quickly have an end-to-end application ready in no time.

RK3576+IMX415 MIPI摄像头零拷贝显示系统 MIPI CSI-2是嵌入式视觉系统中主流的高速图像传感器接口标准,其核心价值在于低延迟、高带宽与硬件级DMA直通能力。基于V4L2子系统与DRM/KMS驱动栈,可构建从传感器RAW数据到帧缓冲区的零拷贝通路,显著降低CPU负载并提升实时性。该技术广泛应用于工业检测、边缘AI推理前数据接入及多路同步采集等场景。本文以Rockchip RK3576 SoC和索尼IMX415传感器为典型组合,详解MIPI物理层适配、内核驱动集成、GStreamer零拷贝管道搭建及systemd服务化部署,覆盖从硬件信号完整性到 阅读详情

相关推荐

51单片机———UART串口通信

传统理解就是信息的传输与交换。单片机与单片机之间,单片机与电脑之间,以及单片机与各式各样的模块之间都可以进行通信。如果没有通信,那么单片机的功能仅仅局限于它本身,它没办法从其他设备获取有用信息,也无法将自己产生的信息告诉其他设备,这样子单片机与外围器件的合作就会收到限制,没办法完成更多的功能,就像一个没办法拓展业务的公司。:实现我们程序当中写的P0=0xFC,就是一次同时对8位进行信号的输出;习惯上,我们还称P0、P1、P2、P3为单片机的4组并行总线:实现低位先发 高位在后。

m0_74225397的博客 3295

java asmx_java调用webservice服务(web服务)(即new Service()报错解决办法)

java调用webservice服务(web服务)(即new Service()报错解决办法)2018-11-23(2011-04-16 16:05:30)标签:newservice()webserviceit分类:Java专区public static String getFlag(String bh,String pwd) throws Exception{String url ="h...

weixin_42144707的博客 916

WPF实战:利用Live Charts实现高性能动态曲线可视化

本文详细介绍了如何在WPF中使用Live Charts实现高性能动态曲线可视化,特别适用于工业监控和金融分析等实时数据场景。通过增量渲染、内存复用和硬件加速等核心技术,Live Charts能够高效处理高频数据更新,显著提升图表流畅度。文章提供了从基础实现到工业级优化的完整解决方案,帮助开发者应对各种性能挑战。

weixin_29189373的博客 407

java flex web_java web开发 flex做前台(下)

第三步tomcat的配置现在遇到一个问题就是,我们需要将web项目发布出去,但是我们有希望可以通过eclipse来编写代码。为此有两种方法可以选择,可以讲eclipse的workspace选择在tomcat的webapps文件夹下,这样做有一些问题会比较麻烦,对于后续程序的更改问题。为此我们选择第二种,你的eclipse的workspace根据自己的情况而选择。假如是D:\eclipse\...

weixin_39886238的博客 165

李宏毅机器学习hw3

Homework 3 - Convolutional Neural Network 1作业概述 在food_11文件中有三个文件分别是training、validation、testing,打开training和validation可以看见总共有11种食物(0-10的类别编号),而testing是没有类别编号的。 然后用卷积神经网络对食物图片进行分类。 2导入用到的库 torch库 这个我弄了半天,直接pip总是timeout,用镜像源下下来又出现OSError: [WinError..

老问题的博客 4188

别再只会插拔了!深入Linux内核,手把手调试USB热插拔中断(以高通平台为例)

本文深入探讨了Linux内核中USB热插拔中断的调试方法,特别针对高通平台提供了详细的实战指南。从硬件基础到内核机制,再到中断调试工具和常见问题排查,帮助开发者系统性地解决USB设备识别问题。通过监控中断状态、分析处理流程和高级调试技巧,提升USB热插拔的稳定性和性能。

weixin_29161785的博客 428

BlazeDS For Flex第一步

下载BlazeDS.war 解压后文件目录如下: Lib下保存jar包: Flex中保存配置文件: Web.xml为配置文件: <servlet> <servlet-name>MessageBrokerServlet</servlet-name> <disp...

142

matlab kwave模拟超声换能器学习笔记

kwave模拟超声换能器的学习笔记,从零开始造车轮

SolvingMaster的博客 3197

java 调用 flex_flex 和java 一起开发.实验远程调用.

首先下载最新的 BlazeDShttp://opensource.adobe.com/blazeds/最新BlazeDS下载地址.http://opensource.adobe.com/wiki/display/blazeds/Release+Builds下面就开始使用flex 创建一个 带java 的web 工程了.创建工程下载的是一个 war 文件..不用解压缩. 这个在创建工程的时候用到. ...

weixin_32865039的博客 192

Framelet Transform

需要定义 Framelet 的基函数。Framelet 基函数可以是通过组合不同的小波函数生成的。# 这里可以定义 Framelet 基函数,例如一些小波基函数的线性组合# 这是一个示例函数,具体实现需要根据具体的 Framelet 设计# 示例:正弦函数。

qq_33009429的博客 1211

使用 MATLAB/Simulink + Simscape Electrical + SimPowerSystems + Stateflow,构建一个多能互补微电网系统的动态响应仿真模型

本文详细介绍了使用MATLAB/Simulink构建多能互补微电网动态响应仿真模型的方法。文章从系统架构设计入手,包含光伏、风电、柴油发电机、锂电池储能等多种组件,重点讲解了建模过程、控制策略(下垂控制、PLL、SOC管理)和模式切换逻辑(Stateflow)。通过四种典型场景(负荷突增、光伏出力骤降、并网/孤岛切换、电动机启动)的仿真分析,验证了微电网在动态响应中的关键性能指标,并提出了高可靠性设计建议。该模型为微电网的稳定性分析和优化设计提供了有效工具,特别强调了储能系统在快速功率支撑中的重要作用。

amy_mhd的博客 160

关于Flex与Web Service的异常处理

作者: 王盛武 FLEX可以接受WSDL类型数据. 但我考虑了一个问题,如果程序遇到异常情况,能正确处理吗? 经过若干的编码测试, 还是不能拿到异常信息. 我找了个测试WEB SERVICE的工具, 输入WSDL地址, 异常信息的确获得到了。自己也写了个JAVA程序调用WSDL,异常也拿到了. 现在的问题是: 异常的确是返回的WSDL里,只是拿不出来. ...

iteye_10233的博客 187

零基础学simulink仿真建模--使用Simulink来构建一个混合动力无人机中燃料电池与锂电池协同控制的仿真模型

延长飞行时间:燃料电池的能量密度高于锂电池,适合长时间稳定供电。提高功率密度:锂电池能够快速响应瞬时高功率需求,比如起飞和加速阶段。优化能源管理:通过有效的能量管理系统,可以根据实际需求动态调整燃料电池和锂电池的工作状态,从而提高整体效率。通过上述步骤,我们简要介绍了如何基于Simulink实现混合动力无人机中燃料电池与锂电池协同控制的仿真模型。

amy_mhd的博客 189

Flex快速入门系列之二:FlashBuilder创建项目以及远程JAVA对象访问(包括spring)篇

前提:一个blazeds-turnkey,是adobe官方提供的访问远程java对象的工具,相关基本概念可参考:http://baike.baidu.com/view/1921230.html,官方文档去http://help.adobe.com/en_US/LiveCycleDataServicesES/3.1/Developing/index.html查看,因为对于最新的blazeds,ado

zhuixunzhe的专栏 2834

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

FLEX和spring、hibernate的集成

flex的后台使用spring+hibernate,spring+hibernate的集成方法和j2ee的项目中方法相同。主要是flex和spring的集成编写SpringFactory.java类:java 代码 package com.fire.spring;       import org.springframework.context.Ap

Eleven's Blog 2874

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

flex java 开发环境搭建_Flex+JAVA+BlazeDS开发环境配置(Java工程和Flex工程独立)

Flex+JAVA+BlazeDS开发环境配置(Java工程和Flex工程独立)2019年12月07日阅读数:7这篇文章主要向大家介绍Flex+JAVA+BlazeDS开发环境配置(Java工程和Flex工程独立),主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。[url]http://blog.youkuaiyun.com/assin/article/details/4277403[/u...

weixin_39640024的博客 272

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

对ADOBE FLEX的十大误解

导读:   对ADOBE FLEX的十大误解  用户不需要安装任何东西就可以运行FLEX应用程序  FLASH播放器其实还是需要的,不过最新的FLASH9的安装覆盖率已经达到了94% FLEX2,3在FP9环境下运行,FLEX应用程序工作在FP API(象矢量图形处理,网络)等,FLEX框架只是使用API构建了可重复使用的组件,象DATE PICKER之类的  对于桌面应用,ADO

The Way To Great 2090

认识Flex Data Services(FDS)

一 FDS相关概念    FDS全称Flex Data Services(现在Adobe将其改名为LiveCycle Data Services),是运行在服务器端的      java程序.它能够运行在大部分的java应用服务器上,包括JRun, JBoss, WebLogic, WebSphere, Oracle     10g, and Tomcat等.使用FDS,能够帮助你创建实时的,数据

没有天赋的IT人 1359

java Web与Flex通过HTTP service 通信 并解析Map 数据。

上篇通过Flex remoting 通信,进入调用方法后,发现并没有获取到Spring 注入的bean对象。bean 为 null so...修改为 HTTPService 的方式。 废话不多说, 1.Flex 通过 HTTPService 请求服务器 代码如下 public function getFlexDupont(companyA:String,companyB:St...

a9809的博客 162

Flex调用java webservice

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="l...

weixin_34008805的博客 149

Flex与Spring进行整合的方式

今天想做整合,将Flex整合到SSH框架中来,由于之前已经将Flex与Java的通信调通,本以为这并不是一件复杂的事。没想到还是搞了两个小时。 我的想法是:Flex调用某个Java文件中的方法,然后我想在我的java方法中,调用Service层的业务逻辑方法。 在编写过程中,发现第一步没有问题,可以成功调用到Java文件中的方法,但第二步就出现问题了,因为Java文件中的Service对象始终

漂泊小柒的专栏 3273
上一篇: learn from tutorials of source code
下一篇: flash decompiler使用手记
zinking3
博客等级 码龄20年 262粉丝 215原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值