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>
相关推荐
Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET By Brian Noyes ............................................... Publisher: Addison Wesley ...
Android Data Binding结合RecyclerView的使用
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 ...
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...
Brian Noyes is a software architect, trainer, writer, and speaker with IDesign (www.idesign.net), a premier .NET architecture and design consulting and training company. He has been developing ...
豆瓣电影搜索 利用Data Binding在RecycleView展示电影列表
Data Binding with Windows Forms 2.0 Programming Smart Client Data Applications with .NET
Android Data Binding实战-入门篇学习笔记,包含实例代码。 基于 Android Studio平台。
以下是Android Architecture Components的优势: ...Android Architecture Components中的Data Binding库可以帮助开发者将数据绑定到UI控件上,以减少手动设置UI控件的代码量,提高开发效率。 5. 易于学习和使用
In this chapter, we examine data binding, the ability to associate non-GUI objects that hold and maintain data with the controls that present and receive that data
AndroidDataBindingExample, Android Data Binding 代码实战
In this chapter, we examine data binding, the ability to associate non-GUI objects that hold and maintain data with the controls that present and receive that data
记一次 Data Binding 在 library module 中遇到的大坑 使用 Data Binding 也有半年多了,从最初的 setVariable,替换 findViewById,到比较高级的双向绑定,自定义 Adapter、Component,查看源码了解编译、运行流程...
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
安卓-Data Binding+RecyclerView打造可以选择的三级列表 博客链接http://blog.csdn.net/Daxue_haha/article/details/77684085
Android Data Binding Adapter for ListView and RecyclerView..zip,使用新的android数据绑定框架将集合绑定到listviews和recyclerviews的简单方法
微软的示例! VB.net的 数据绑定!
Android数据绑定的一个Demo程序,包括数据绑定和事件绑定