Frontend
CXF provides the concept of frontend modeling, which lets you create web services
using different frontend APIs. The APIs let you create a web service using simple
factory beans and JAX-WS implementation. It also lets you create dynamic web
service clients. The primary frontend supported by CXF is JAX-WS. We will look
at how to use the Frontend programming model in the next chapter.
JAX-WS
JAX-WS is a specification that establishes the semantics to develop, publish, and
consume web services. JAX-WS simplifies web service development. It defines
Java-based APIs that ease the development and deployment of web services.
The specification supports WS-Basic Profile 1.1 that addresses web service
interoperability. It effectively means a web service can be invoked or consumed by
a client written in any language. JAX-WS also defines standards such as JAXB and
SAAJ. CXF provides support for complete JAX-WS stack.
JAXB provides data binding capabilities by providing a convenient way to map XML
schema to a representation in Java code. The JAXB shields the conversion of XML
schema messages in SOAP messages to Java code without the developers seeing
XML and SOAP parsing. JAXB specification defines the binding between Java and
XML Schema. SAAJ provides a standard way of dealing with XML attachments
contained in a SOAP message.
JAX-WS also speeds up web service development by providing a library of
annotations to turn Plain Old Java classes into web services and specifies a detailed
mapping from a service defined in WSDL to the Java classes that will implement that
service. Any complex types defined in WSDL are mapped into Java classes following
the mapping defined by the JAXB specification.
As discussed earlier, two approaches for web service development exist: Code-First
and Contract-First. With JAX-WS, you can perform web service development using
one of the said approaches, depending on the nature of the application.
With the Code-first approach, you start by developing a Java class and interface and
annotating the same as a web service. The approach is particularly useful where
Java implementations are already available and you need to expose implementations
as services.
You typically create a Service Endpoint Interface (SEI) that defines the service
methods and the implementation class that implements the SEI methods. The
consumer of a web service uses SEI to invoke the service functions. The SEI directly
corresponds to a wsdl:portType element. The methods defined by SEI correspond
to the wsdl:operation element.
@WebService
public interface OrderProcess {
String processOrder(Order order);
}
JAX-WS makes use of annotations to convert an SEI or a Java class to a web
service. In the above example, the @WebService annotation defined above the
interface declaration signifies an interface as a web service interface or Service
Endpoint Interface.
In the Contract-first approach, you start with the existing WSDL contract, and generate
Java class to implement the service. The advantage is that you are sure about what to
expose as a service since you define the appropriate WSDL Contract-first. Again the
contract definitions can be made consistent with respect to data types so that it can be
easily converted in Java objects without any portability issue. In Chapter 3 we will look
at how to develop web services using both these approaches.
WSDL contains different elements that can be directly mapped to a Java class
that implements the service. For example, the wsdl:portType element is directly
mapped to SEI, type elements are mapped to Java class types through the use of Java
Architecture of XML Binding (JAXB), and the wsdl:service element is mapped to
a Java class that is used by a consumer to access the web service.
The WSDL2Java tool can be used to generate a web service from WSDL. It has various
options to generate SEI and the implementation web service class. As a developer,
you need to provide the method implementation for the generated class. If the WSDL
includes custom XML Schema types, then the same is converted into its equivalent
Java class.
Simple frontend
Apart from JAX-WS frontend, CXF also supports what is known as 'simple frontend'.
The simple frontend provides simple components or Java classes that use reflection
to build and publish web services. It is simple because we do not use any annotation
to create web services. In JAX-WS, we have to annotate a Java class to denote it
as a web service and use tools to convert between a Java object and WSDL. The
simple frontend uses factory components to create a service and the client. It does
so by using Java reflection API. In Chapter 3 we will look at how to develop simple
frontend web services
The following code shows a web service created using simple frontend:
// Build and publish the service
OrderProcessImpl orderProcessImpl = new OrderProcessImpl();
ServerFactoryBean svrFactory = new ServerFactoryBean();
svrFactory.setServiceClass(OrderProcess.class);
svrFactory.setAddress("http://localhost:8080/OrderProcess");
svrFactory.setServiceBean(orderProcessImpl);
svrFactory.create();
相关推荐
赠送jar包:cxf-rt-frontend-jaxrs-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-jaxrs-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-jaxrs-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-jaxrs...
赠送jar包:cxf-rt-frontend-jaxws-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-jaxws-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-jaxws-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-jaxws...
"wp-user-frontend-pro"是一款针对WordPress平台的专业前端表单编辑插件,它极大地扩展了网站用户在前段操作的功能,允许非管理员级别的用户在不进入后台的情况下进行文章的编辑和发布。这款插件旨在提升用户体验,...
Java前端(FrontEnd)是一种用于Java程序反编译的工具,它可以帮助开发者查看和理解已编译的Java字节码。在软件开发过程中,源代码通常被编译成字节码,这是一种平台无关的中间语言,Java虚拟机(JVM)能够理解和...
赠送jar包:cxf-rt-frontend-simple-3.0.1.jar; 赠送原API文档:cxf-rt-frontend-simple-3.0.1-javadoc.jar; 赠送源代码:cxf-rt-frontend-simple-3.0.1-sources.jar; 赠送Maven依赖信息文件:cxf-rt-frontend-...
标题"jsonrpc-frontend:前端应用程序发送 json-rpc 请求进行测试"表明我们要讨论的是一个专门针对前端应用的库或工具,它帮助开发者方便地发送JSON-RPC请求进行功能测试。这个工具可能包括对JSON-RPC规范的实现、...
4. **FrontEnd Plus.txt**:这个文件可能是关于"FrontEnd"的附加信息或者使用手册,可能包含"FrontEnd plus v0.01"的特性、更新日志、使用教程等。 综合来看,这个压缩包可能包含了一个自定义的Java应用描述符工具...
UPX Frontend v3.01 是一个专为IT专业人士设计的应用软件,它提供了一种图形用户界面(GUI)来简化UPX(Ultimate Packer for eXecutables)的使用过程。UPX是一款开源的、免费的、强大的可执行文件打包器,能够对...
本文将深入探讨“FrontEnd”这一专为JAD设计的图形化操作界面,以及其在反编译过程中的作用。 JAD,全称为Java Application Decompiler,是一款功能强大的Java字节码反编译器。它能够将已编译的Java字节码(.class...
其中,"FrontEnd V2.03"是一款著名的Java CLASS文件反编译工具,专为Java开发者设计,以帮助他们查看和理解Java字节码。这个工具不仅提供了基本的反编译功能,还有其他一些实用特性,使其在同类工具中脱颖而出。 ...