The starting point for developing a JAX-WS web service is a Java class annotated with the javax.jws.WebService annotation. The @WebService annotation defines the class as a web service endpoint.
A service endpoint interface or service endpoint implementation (SEI) is a Java interface or class, respectively, that declares the methods that a client can invoke on the service. An interface is not required when building a JAX-WS endpoint. The web service implementation class implicitly defines an SEI.
You may specify an explicit interface by adding the endpointInterface element to the @WebService annotation in the implementation class. You must then provide an interface that defines the public methods made available in the endpoint implementation class.
JAX-WS endpoints must follow these requirements:
The implementing class must be annotated with either the javax.jws.WebService or javax.jws.WebServiceProvider annotation.
The implementing class may explicitly reference an SEI through the endpointInterface element of the @WebService annotation, but is not required to do so. If no endpointInterface is specified in @WebService, an SEI is implicitly defined for the implementing class.
The business methods of the implementing class must be public, and must not be declared static or final.
Business methods that are exposed to web service clients must be annotated with javax.jws.WebMethod.
Business methods that are exposed to web service clients must have JAXB-compatible parameters and return types. See Default Data Type Bindings.
The implementing class must not be declared final and must not be abstract.
The implementing class must have a default public constructor.
The implementing class must not define the finalize method.
The implementing class may use the javax.annotation.PostConstruct or javax.annotation.PreDestroy annotations on its methods for life cycle event callbacks.
The @PostConstruct method is called by the container before the implementing class begins responding to web service clients.
The @PreDestroy method is called by the container before the endpoint is removed from operation.
When invoking the remote methods on the port, the client performs these steps:
Uses the javax.xml.ws.WebServiceRef annotation to declare a reference to a web service. @WebServiceRef uses the wsdlLocation element to specify the URI of the deployed service’s WSDL file.
@WebServiceRef(wsdlLocation="http://localhost:8080/helloservice/hello?wsdl")
static HelloService service;Retrieves a proxy to the service, also known as a port, by invoking getHelloPort on the service.
Hello port = service.getHelloPort();The port implements the SEI defined by the service.
Invokes the port’s sayHello method, passing to the service a name.
String response = port.sayHello(name);
JAXB supports the grouping of generated classes in Java packages. A package consists of the following:
A Java class name that is derived from the XML element name, or specified by a binding customization.
An ObjectFactory class, which is a factory that is used to return instances of a bound Java class.
When XML element information can not be inferred by the derived Java representation of the XML content, a JAXBElement object is provided. This object has methods for getting and setting the object name and object value
Custom JAXB binding declarations allow you to customize your generated JAXB classes beyond the XML-specific constraints in an XML schema to include Java-specific refinements, such as class and package name mappings.
JAXB provides two ways to customize an XML schema:
As inline annotations in a source XML schema
As declarations in an external binding customization file that is passed to the JAXB binding compiler
The JAXB annotations defined in the javax.xml.bind.annotations package can be used to customize Java program elements to XML schema mapping.
分享到:
相关推荐
标题"jax-rs jax-ws所需包,亲测可用"表明这个压缩包包含了用于开发Java RESTful Web服务(JAX-RS)和Java SOAP Web服务(JAX-WS)所需的库文件。这些库是Java应用程序进行Web服务交互的核心组件,确保了对HTTP协议...
Java API for XML Web Services(JAX-WS)是Java平台上用于构建和消费Web服务的标准API。它简化了创建和使用Web服务的过程,使得开发者能够通过SOAP消息与远程服务进行交互。JAX-WS允许开发者将服务接口直接映射到...
在WebLogic服务器上部署JAX-WS服务时,可能会遇到一些配置问题。JAX-WS(Java API for XML Web Services)是Java平台上的一个标准,用于创建和部署Web服务。WebLogic作为一款强大的Java EE应用服务器,支持JAX-WS...
标题提到的"JAX-WS所需Jar包"是指为了在Java环境中支持JAX-WS功能,开发者需要的一组核心库。这些库包含了运行和开发JAX-WS Web服务所必需的组件。下面将逐一解释这些库的作用: 1. **jaxb-xjc.jar**: 这是Java ...
在给定的压缩包文件"jax-ws api jar包"中,包含的是JAX-WS 2.2.1版本的API库,即`jaxws-api-2.2.1.jar`。这个jar文件是开发基于JAX-WS的Web服务所必需的依赖之一。以下是关于JAX-WS的一些核心知识点: 1. **服务端...
JAX-WS 2.0是JAX-WS的第二个主要版本,它在JAX-RPC(Java API for XML-based RPC)的基础上进行了改进,引入了许多新特性以提升开发者的体验和效率。 **JAX-WS 2.0 的核心概念:** 1. **服务端点接口(SEI, ...
标题中的“一个包含jax-ws和jax-rs的例子(含服务端和客户端)”是指这是一个示例项目,它演示了如何使用Java API for XML Web Services (JAX-WS)和Java API for RESTful Web Services (JAX-RS)来创建和消费Web服务。...
**JAX-WS2.1用户指南** JAX-WS(Java API for XML Web Services)是Java平台上用于创建Web服务的标准API,版本2.1是其一个重要里程碑。本指南将深入探讨JAX-WS 2.1的核心概念、功能以及如何在实际开发中应用它。...
**JAX-WS API** Java API for XML Web Services (JAX-WS) 是Java平台上的一个标准接口,用于创建和消费Web服务。它是Sun Microsystems在2004年推出的一个重要框架,旨在简化Web服务的开发,使得Java开发者能够更...
【标题】:Web服务之Java API for XML Web Services (JAX-WS) 【内容详解】 JAX-WS,全称为Java API for XML Web Services,是Java平台上的一个标准,用于构建和部署基于SOAP(Simple Object Access Protocol)的...
JAX-WS(Java API for XML Web Services)是Java平台上的一个标准,用于创建和消费Web服务。本篇将深入讲解如何基于JAX-WS开发一个WebService实例。 首先,让我们了解JAX-WS的基本概念。JAX-WS提供了一种简单的方式...
【标题】"metro-jax-ws-jaxws221x.zip" 提供的是一个关于JAX-WS(Java API for XML Web Services)的开发示例,其中包含了JAX-WS 2.2.1版本的相关组件和库文件。这个压缩包是针对Java开发者设计的,用于帮助他们理解...
**JAX-WS规范详解** Java API for XML Web Services(JAX-WS)是Java平台上的一个标准,用于创建Web服务和客户端。它提供了一种简单、类型安全的方式来构建和消费基于SOAP的消息传递应用程序,是Java世界中实现Web...
**标题:“jax-ws2.1.zip”**指的是一个包含Java API for XML Web Services(JAX-WS)2.1版本的压缩包。JAX-WS是Java平台标准版(Java SE)和企业版(Java EE)的一部分,用于构建基于SOAP(Simple Object Access ...
JAX-WS 2.2 RI 所包含的JAR包集合,包含25个JAR包,列表如下: FastInoset.jar gmbal-api-only.jar ha-api.jar javax.annotation.jar javax.mail_1.4.jar jaxb-api.jar jaxb-impl.jar jaxb-xjc.jar jaxws-api...
Java API for XML Web Services(JAX-WS)是Java平台上的一个标准,用于构建和部署Web服务。它简化了Web服务的开发,使得Java开发者能够更方便地创建、调用和部署SOAP(Simple Object Access Protocol)服务。在这个...
Java API for XML Web Services (JAX-WS) 是Java平台上的一个标准,用于构建和部署Web服务。JAX-WS RI(Reference Implementation)是这个规范的官方参考实现,它提供了开发、测试和运行基于SOAP(Simple Object ...
基于jax-ws 实现的web service client和server端的demo程序。 注:如果使用的是 myeclipse 时 server 部署到tomcat 启动的时候会报错 解决办法:找到myeclipse安装目录下的 plugins 目录里 查找 webservices-rt.jar,...
Java API for XML Web Services(JAX-WS)是Java平台上的一个标准,用于构建和部署Web服务。它简化了Web服务的开发,使得开发者能够使用Java编程语言来创建、调用和部署SOAP(Simple Object Access Protocol)服务。...
**标题解析:** "JAX-WS低版本" 指的是Java API for XML Web Services的一个较早的发行版。JAX-WS是Java平台上用于创建Web服务的标准API,它简化了开发和部署基于SOAP(Simple Object Access Protocol)的Web服务和...