You can define the HTTP client properties and user custom
properties by using the ibm-ws-bnd.xml file for
JAX-WS applications on the Liberty profile.
Before you begin
The ibm-ws-bnd.xml file
must be in the /WEB-INF directory of a web-based
web services application (WAR file), or in the /META-INF directory
of a EJB-based web service application (JAR file).
About this task
HTTP client properties and user custom properties can
be defined by using the
service-ref and
port elements
in the
ibm-ws-bnd.xml file for the specific service
client or port that is injected by the
@WebServiceRef annotation.
Properties in the
port element override the same
properties in the
service-ref element.
- HTTP client properties
- The following HTTP client properties are supported in the Liberty
profile; these properties must have the prefix http.conduit.client..
For example: http.conduit.client.ConnectionTimeout.
These HTTP client properties are valid only when sending or receiving
SOAP messages, and they are not applicable when connecting to a WSDL
URL.
- ConnectionTimeout
- ReceiveTimeout
- AsyncExecuteTimeout
- AsyncExecuteTimeoutRejection
- AutoRedirect
- MaxRetransmits
- AllowChunking
- ChunkingThreshold
- Connection
- DecoupledEndpoint
- ProxyServer
- ProxyServerPort
- ProxyServerType
- NonProxyHosts
- For more information about these properties, see HTTP
configuration schema in Apache CXF and Client HTTP Transport (including SSL support) .
- User Custom Properties
- Besides the supported HTTP client properties in the Liberty profile,
you can define the user custom properties that might be used in your
application, and retrieve these properties from the client request
context. All attributes defined in the properties element
will be put into the service client request context.
For all available elements that you
can configure within the ibm-ws-bnd.xml file,
see Liberty profile: The ibm-ws-bnd.xml file.
Procedure
- Configure HTTP conduit properties. The following
examples shows how to configure HTTP client properties ConnectionTimeout and ReceiveTimeout in
the ibm-ws-bnd.xml file. The following example
shows how to apply the HTTP client properties ConnectionTimeout and ReceiveTimeout for
all the ports of the service client injected by using the @WebServiceRef(name="service/SimpleEchoService"),
and for the port SimpleEchoPort, the value of user
custom property vendor is also applied.
<?xml version="1.0" encoding="UTF-8"?>
<webservices-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd"
version="1.0">
<service-ref name="service/SimpleEchoService">
<port name="SimpleEchoPort">
<properties vendor="IBM" />
</port>
<properties http.conduit.client.ConnectionTimeout="10000"
http.conduit.client.ReceiveTimeout="15000" />
</service-ref>
...
</webservices-bnd>
- Then retrieve the properties defined in the ibm-ws-bnd.xml file
from the request context of the client that is injected by the @WebServiceRef(name="service/SimpleEchoService") annotation
as follows.
@WebServiceRef(name="service/SimpleEchoService")
private EchoService echoService;
...
Echo echo = echoService.getEchoPort();
BindingProvider bp = (BindingProvider)echo;
String connTimeout = bp.getRequestContext().get("http.conduit.client.ConnectionTimeout").toString();
String recTimeout = bp.getRequestContext().get("http.conduit.client.ReceiveTimeout").toString();
String vendor = bp.getRequestContext().get("vendor").toString();
...