You can add binding extensions in the WSDL document, an then apply the extensions into
your applications with JAX-WS support on Liberty.
About this task
Liberty supports the use of the
wsdl:binding extension that is required in the JAX-WS 2.2 specification. This topic
describes how to define the WSDL extensions, and bind them with the customized extensibility element
in Liberty.
Procedure
- Define an extensibility element and map it to the user that is defined in the WSDL extension. The following example shows how to bind with the WSDL extension
{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;
}
}
- Add the extensions.xml file into the /META-INF
directory of your web or EJB application. This file defines where the extensions can be used in the
WSDL document. In the following example, an entry to set the javax.wsdl.Binding property
as the parent type of the goodBindingElement class is added in the
extensions.xml file. The entry also means that the extension
{http://server.respectbinding.jaxws22/}goodBinding can be only added under the
binding element in the WSDL
document.
<?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>
- Add the extension {http://server.respectbinding.jaxws22/}goodBinding under the
binding element as follows:
...
<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>
...