在 JAX-WS Web Service 中强制遵循 WSDL 绑定
在 WSDL 文档中添加绑定扩展,然后将扩展应用到 Liberty 上具有 JAX-WS 支持的应用程序。
关于此任务
Liberty 支持使用 JAX-WS 2.2 规范中所需的 wsdl:binding 扩展。本主题描述如何定义 WSDL 扩展,并使这些扩展与 Liberty 中的定制可扩展性元素相绑定。
过程
- 定义可扩展性元素并将其映射至 WSDL 扩展中定义的用户。 以下示例显示如何与 WSDL 扩展 {http://server.respectbinding.jaxws22/}goodBinding 绑定。
@XmlRootElement(name = "goodBinding", namespace = "http://server.respectbinding.jaxws22/") public class GoodBindingElement implements ExtensibilityElement, Serializable { private String uri; private QName elementType = null; private Boolean required = null; @XmlAttribute(name = "uri") public String getUri() { return this.uri; } @Override public QName getElementType() { return this.elementType; } @XmlAttribute(name = "required", namespace="http://schemas.xmlsoap.org/wsdl/") public Boolean getRequired() { return this.required; } public void setUri(String uri){ this.uri = uri; } @Override public void setElementType(QName elementType) { this.elementType = elementType; } @Override public void setRequired(Boolean required) { this.required = required; } }
- 将 extensions.xml 文件添加到 Web 或 EJB 应用程序的 /META-INF 目录。此文件定义 WSDL 文档中可以使用扩展的位置。 在以下示例中,extensions.xml 文件中添加了一个用来将 javax.wsdl.Binding 属性设置为 goodBindingElement 类的父类型的条目。该条目也意味着扩展 {http://server.respectbinding.jaxws22/}goodBinding 只能添加到 WSDL 文档中的 binding 元素。
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <!-- XML Binding --> <entry key="org.apache.cxf.bindings.xml-1">javax.wsdl.Binding=jaxws22.respectbinding.server.common.GoodBindingElement</entry> </properties>
- 将扩展 {http://server.respectbinding.jaxws22/}goodBinding 添加到 binding 元素下方,如下所示:
... <binding name="EchoPortBinding" type="tns:Echo"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> <tns:goodBinding wsdl:required="true" uri="http://good/good" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" /> <operation name="echo"> <soap:operation soapAction=""/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> <fault name="Exception"> <soap:fault name="Exception" use="literal"/> </fault> </operation> </binding> ...


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_dep_jaxws_extension
文件名:twlp_dep_jaxws_extension.html