`
zsjg13
  • 浏览: 144931 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论

Data binding

    博客分类:
  • CXF
阅读更多

Data binding

Data binding is the key for any web service development. Data binding means 

mapping between Java objects and XML elements. As we know, with web service, 

messages are exchanged as XML artifacts. So there has to be some way to convert 

these XML into Java objects and vice versa for the application to process as service 

and client. Data binding components perform this mapping for you. CXF supports 

two types of data binding components—JAXB and Aegis. CXF uses JAXB as the 

default data binding component. As a developer, you have the choice of specifying 

the binding discipline through a configuration file or API. If no binding is specified, 

then JAXB is taken as a default binding discipline. The latest version of CXF uses 

JAXB 2.1. JAXB uses annotations to define the mapping between Java objects and 

XML. The following code illustrates the use of JAXB annotations:

 

@XmlRootElement(name="processOrder", namespace=" http://localhost/ 

                      orderprocess")

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name="processOrder", namespace= 

              " http://localhost/orderprocess")

public class OrderProcess {

    @XmlElement(name="arg0", namespace="")

    private order.Order arg0;

   //Gettter and Setter 

….

 

}

As shown in the previous code, the @Xml specific annotations represents the JAXB 

metadata that is used by JAXB to map Java classes to XML schema constructs. For 

example, the @XmlType annotation specifies that the OrderProcess class will be 

mapped to complex XSD element type 'processOrder' that contains an element 

'arg0' of type 'Order' bean.

 

CXF also supports the Aegis data binding component to map between Java objects 

and XML. Aegis allows developers to gain control of data binding through its 

flexible mapping system. You do not have to rely on annotations to devise the 

mapping. Your Java code is clean and simple POJO. 

 

Aegis also supports some annotations that can be used to devise binding. Some of 

the annotations that can be used with Aegis are:

• XmlAttribute

• XmlElement

• XmlParamType

• XmlReturnType

• XmlType

 

In Aegis, you define the data mapping in a file called  <MyJavaObject>.aegis.xml, 

where MyJavaObject is the object that you are trying to map with XML. Aegis reads 

this XML to perform the necessary binding. Aegis also uses reflection to derive the 

mapping between Java object and XML. The following code fragment shows the 

sample Aegis mapping file: 

<?xml version="1.0" encoding="UTF-8"?>

<mappings>

    <mapping name="HelloWorld">

        <method name="sayHi">

            <parameter index="0" mappedName= 

                             "greeting" nillable='false' />

        </method>

    </mapping>

</mappings>

The above XML fragment states that a string parameter of a method named sayHi of 

the bean HelloWorld should be mapped to a name as greeting.

 

You can configure your web service to use Aegis data binding as follows:

<jaxws:endpoint id="orderProcess" implementor="demo.order.

OrderProcessImpl" address="/OrderProcess" >

   <jaxws:dataBinding>

    <bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />

   </jaxws:dataBinding>

</jaxws:endpoint>

分享到:
评论

相关推荐

    Android Data Binding

    Android Data Binding库是Google推出的一种强大的MVVM(Model-View-ViewModel)架构支持技术,它旨在简化Android应用中的UI逻辑,提高代码可读性和可维护性。本教程将深入探讨如何将Data Binding与RecyclerView结合...

    Data Binding with Windows Forms 2.0

    Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET By Brian Noyes ............................................... Publisher: Addison Wesley ...

    Android Data Binding 代码实战 demo

    **Android Data Binding 框架详解与实战演示** 在Android应用开发中,数据绑定是一种将UI组件和数据源紧密关联的技术,它可以帮助开发者减少在Activity或Fragment中的样板代码,提高代码可读性和维护性。本实战项目...

    Android Data Binding实战-入门篇

    Android Data Binding是Google推出的一种强大的数据绑定库,它旨在简化Android应用中的UI逻辑,通过将数据绑定到XML布局文件中,使代码更加清晰、可读性更强,同时也减少了Activity或Fragment中的样板代码。...

    Flex Data Binding详解

    Flex Data Binding是Adobe Flex框架中的核心特性之一,它允许开发者创建数据驱动的应用程序,通过将UI组件的属性与数据模型的属性直接关联,实现实时的数据同步。在Flex中,数据绑定确保当数据源发生变化时,相关的...

    AdventureWorks Data Binding sample

    本文将深入探讨“AdventureWorks Data Binding sample”,这是微软提供的一款用于演示VB.NET数据绑定特性的实例。 首先,让我们了解数据绑定的基本概念。数据绑定允许UI控件(如文本框、列表视图等)直接与数据源...

    WPF Data Binding with LINQ to SQL

    These tutorials describe how to map your classes to your tables manually (rather than with an automated tool like SqlMetal) so that you can have support for M:M relationships and data binding against ...

    Android数据绑定Data Binding

    在Android开发中,数据绑定(Data Binding)是一个强大的框架,它允许开发者更加直观地将UI组件与业务数据关联起来,从而简化代码并提高可维护性。这个Demo程序旨在展示数据绑定和事件绑定的基本用法,帮助开发者...

    Data Binding with Windows Forms 2.0 Programming

    This book is all about the what and the why of binding to data sources in a Windows Forms application built using Visual Studio 2005. The book goes into great detail in explaining the rationale behind...

    AndroidDataBindingExample, Android Data Binding 代码实战.zip

    Android Data Binding 是 Android 平台上的一种强大的数据绑定框架,它简化了UI与数据之间的交互,使得开发者能够更专注于业务逻辑,而不是繁琐的事件处理和视图更新。这个压缩包"AndroidDataBindingExample, ...

    Android Data Binding 在 library module 中遇到错误及解决办法

    在使用Android Data Binding时,有时会遇到在library module中出现错误的情况。这通常是由于Data Binding在编译过程中生成的binding类与library module的特定规则不兼容导致的。本文将深入探讨这个问题并提供解决...

    安卓-Data Binding+RecyclerView打造可以选择的三级列表

    在安卓应用开发中,构建可交互的用户界面是至关重要的,而Data Binding库与RecyclerView的结合使用能够有效地提高代码的可读性和维护性,同时实现复杂的列表展示,如本示例中的三级列表。本文将详细解析如何利用Data...

    Data Binding with Windows Forms 2.0 Programming Smart Client Data Applications with .NET

    《Data Binding with Windows Forms 2.0:编程智能客户端数据应用程序与.NET》是一本深入探讨.NET框架下Windows Forms 2.0数据绑定技术的专业书籍。数据绑定是将用户界面(UI)组件与数据源连接的过程,它使得应用...

    Data Binding and Explicit Transactions

    在IT行业中,数据绑定(Data Binding)和显式事务(Explicit Transactions)是两个非常关键的概念,尤其是在处理数据存储和更新时。这篇博文“Data Binding and Explicit Transactions”将深入探讨这两个主题,帮助...

    Andro使用Data Binding将数据绑定到UI控件再使用RxBindings处理UI事件,实现双向数据流和响应式编程

    以下是Android Architecture Components的优势: ...Android Architecture Components中的Data Binding库可以帮助开发者将数据绑定到UI控件上,以减少手动设置UI控件的代码量,提高开发效率。 5. 易于学习和使用

    Android Data Binding Library 官方文档(译)

    Android Data Binding Library 官方文档中文翻译,出自https://blog.csdn.net/jjwwmlp456/article/details/54915981的博客,被我制作成离线版pdf以供保存, Google官方文档地址:...

    Approaches and Best Practices in Web Service Style, Data Binding and Validation.pdf

    本文档探讨了网络服务(Web services)的各种风格及其在数据绑定(data binding)和验证(validation)方面的不同方法,旨在为大型系统开发提供指导。网络服务作为现代分布式计算的核心组成部分,其设计与实现对系统...

    Android Data Binding Adapter for ListView and RecyclerView..zip

    Android Data Binding Adapter for ListView and RecyclerView..zip,使用新的android数据绑定框架将集合绑定到listviews和recyclerviews的简单方法

Global site tag (gtag.js) - Google Analytics