JAX-WS Client Handler

Write a handler class implementing SOAPHandler
Define handler chain in the client bindings XML file

<bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    wsdlLocation="http://localhost:8080/jaxws-fromjavahandler/addnumbers?wsdl"
    xmlns="http://java.sun.com/xml/ns/jaxws">
    <bindings node="wsdl:definitions" xmlns:jws="http://java.sun.com/xml/ns/javaee">
        <jws:handler-chains>
            <jws:handler-chain>
                <jws:handler>
                    <jws:handler-class>fromjavahandler.common.LoggingHandler</jws:handler-class>
                </jws:handler>
            </jws:handler-chain>
        </jws:handler-chains>
    </bindings>
</bindings>

Add binding config file to generate-client Ant target

<target name="generate-client" depends="setup">
  <wsimport
    debug="true"
    verbose="${verbose}"
    keep="true"
    binding="${basedir}/etc/custom-client.xml"
    destdir="${build.classes.home}"
    package="fromjavahandler.client"
    wsdl="http://localhost:8080/jaxws-fromjavahandler/addnumbers?wsdl">
  </wsimport>
</target>

Build client and run

This entry was posted in jax-ws, soa. Bookmark the permalink.