SOAP Message Handlers Quick Reference for Java EE 6 Web Services Certification Exam 1z0-897

SOAP message handlers enable Web Services and clients to perform additional processing on the SOAP message request or response, by intercepting the SOAP message in both the request and response of the Web Service. 


SOAP handlers and logical handlers

  • JAX-WS supports two types of SOAP message handlers:

    • SOAP handlers

      • SOAP handlers can access the entire SOAP message, including the message headers and body.

    • Logical handlers

      • Logical handlers can access the payload of the message only, and cannot change any protocol-specific information (like headers) in a message.

  • SOAPHandlers in the order specified in configuration are executed first and then the LogicalHandlers specified in the order get executed.


Configuring SOAP Handlers

  • Java EE container does not automatically processes the handlers packaged in the application and configures it on the applicable endpoint, you will need to configure using one of the available ways.

  • Handlers can be configured for:

    • endpoints configured with @WebService

    • endpoints configured with @WebServiceProvider

    • endpoints in the deployment descriptor (webservices.xml)

  • In bottom up web service development, Handlers can be configured using @HandlerChain annotation on endpoints configured with @WebService or wit.h @WebServiceProvider.

    • E.g. @HandlerChain(file="handler-chain.xml")

    • The file attribute is used to specify an external file that contains the configuration of the handler chain.

      • The external handler chain configuration file contains configuration information for the handler chain such as the list of handlers in the handler chain, the order in which they execute, the initialization parameters, and so on.

    • It is an error to specify more than one @HandlerChain annotation in a single Java file.

  • In top down web service development, handler chain configuration can be done through WSDL customizations.

    • A <handlerChains> element is added to the customization file.

    • Multiple handler-chain elements may exist within the handler-chains element.

      • These may optionally use a service name, port name, or protocol pattern in their description to apply some chains to certain ports and protocols only, through the use of <service-name-pattern> element.


Configuring handlers on a Web Service client

We can configuring handlers on a Web Service client in one of the following ways:

  • Create a handlerchain as list of handlers and call setHandlerChain() with that list on the Binding object.

  • Programmatically configure the handlers by setting a custom HandlerResolver on the service instance and create proxies from that service.

  • Specify handlers in handler chain configuration XML file and add @HandlerChain referencing handler configuration file to the Web Service references for clients running in JavaEE Container.



Example (part)  - configuring handlers as annotations (provider-side)

@WebService(name = "Handler", targetNamespace = "")



Example (part)  - configuring handlers as wsdl customization bindings (provider-side)

<bindings xmlns="">
  <handler-chains xmlns="">


Example (part) - <service-name-pattern> element (provider-side)

<handler-chains xmlns="">
      <service-name-pattern xmlns:ns1="">ns1:Hello*</service-name-pattern>

Here, the <service-name-pattern> element applies the handlers in the specified in the <handler-chain> element to the service whose name begins with Hello and targetNamespace is

Quick Notes Finder Tags

Activities (1) advanced java (1) agile (3) App Servers (6) archived notes (2) ArrayLists (1) Arrays (2) Best Practices (12) Best Practices (Design) (3) Best Practices (Java) (7) Best Practices (Java EE) (1) BigData (3) Chars & Encodings (6) coding problems (2) Collections (15) contests (3) Core Java (All) (53) course plan (2) Database (12) Design patterns (8) dev tools (3) downloads (2) eclipse (9) Essentials (1) examples (14) Exception (1) Exceptions (4) Exercise (1) exercises (6) Getting Started (18) Groovy (2) hadoop (4) hibernate (77) hibernate interview questions (6) History (1) Hot book (5) http monitoring (2) Inheritance (4) intellij (1) java 8 notes (4) Java 9 (1) Java Concepts (7) Java Core (8) java ee exercises (1) java ee interview questions (2) Java Elements (16) Java Environment (1) Java Features (4) java interview points (4) java interview questions (4) javajee initiatives (1) javajee thoughts (3) Java Performance (6) Java Programmer 1 (12) Java Programmer 2 (8) Javascript Frameworks (1) Java SE Professional (1) JPA 1 - Module (6) JPA 1 - Modules (1) JSP (1) Legacy Java (1) linked list (3) maven (1) Multithreading (16) NFR (1) No SQL (1) Object Oriented (9) OCPJP (4) OCPWCD (1) OOAD (3) Operators (4) Overloading (2) Overriding (2) Overviews (1) policies (1) programming (1) Quartz Scheduler (1) Quizzes (17) RabbitMQ (1) references (2) resources (1) restful web service (3) Searching (1) security (10) Servlets (8) Servlets and JSP (31) Site Usage Guidelines (1) Sorting (1) source code management (1) spring (4) spring boot (3) Spring Examples (1) Spring Features (1) spring jpa (1) Stack (1) Streams & IO (3) Strings (11) SW Developer Tools (2) testing (1) troubleshooting (1) user interface (1) vxml (8) web services (1) Web Technologies (1) Web Technology Books (1) youtube (1)