Java SOAP Message addMessageHandler(Object binding, SOAPHandler handler)

Here you can find the source of addMessageHandler(Object binding, SOAPHandler handler)

Description

Add a message handler to a SOAP binding

License

Apache License

Parameter

Parameter Description
binding binding to which we'll add the handler
handler the handler to be added

Declaration

@SuppressWarnings({ "unchecked", "rawtypes" })
public static void addMessageHandler(Object binding, SOAPHandler<SOAPMessageContext> handler) 

Method Source Code

//package com.java2s;
/*//from   w  w  w  .jav  a2  s.c o m
       
   Copyright 2012 VU Medical Center Amsterdam
       
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
       
   http://www.apache.org/licenses/LICENSE-2.0
       
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
       
*/

import java.util.ArrayList;
import java.util.List;

import javax.xml.ws.Binding;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;

public class Main {
    /**
     * Add a message handler to a SOAP binding
     * @param binding binding to which we'll add the handler
     * @param handler the handler to be added
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static void addMessageHandler(Object binding, SOAPHandler<SOAPMessageContext> handler) {
        final Binding b = ((BindingProvider) binding).getBinding();
        List handlerList = b.getHandlerChain();
        if (handlerList == null)
            handlerList = new ArrayList();
        handlerList.add(handler);
        b.setHandlerChain(handlerList);
    }

    /**
     * Add a message handler to a SOAP binding
     * @param binding binding to which we'll add the handler
     * @param handler the handler to be added
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static void addMessageHandler(Object binding, LogicalHandler handler) {
        final Binding b = ((BindingProvider) binding).getBinding();
        List handlerList = b.getHandlerChain();
        if (handlerList == null)
            handlerList = new ArrayList();
        handlerList.add(handler);
        b.setHandlerChain(handlerList);
    }

    /**
     * Add a message handler to a SOAP binding
     * @param binding binding to which we'll add the handler
     * @param index position in the list of handlers
     * @param handler the handler to be added
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static void addMessageHandler(Object binding, int index, SOAPHandler<SOAPMessageContext> handler) {
        final Binding b = ((BindingProvider) binding).getBinding();
        List handlerList = b.getHandlerChain();
        if (handlerList == null)
            handlerList = new ArrayList();
        handlerList.add(index, handler);
        b.setHandlerChain(handlerList);
    }

    /**
     * Add a message handler to a SOAP binding
     * @param binding binding to which we'll add the handler
     * @param index position in the list of handlers
     * @param handler the handler to be added
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public static void addMessageHandler(Object binding, int index, LogicalHandler handler) {
        final Binding b = ((BindingProvider) binding).getBinding();
        List handlerList = b.getHandlerChain();
        if (handlerList == null)
            handlerList = new ArrayList();
        handlerList.add(index, handler);
        b.setHandlerChain(handlerList);
    }
}

Related

  1. addAttachment(SOAPMessage soapMessage, String payloadId, String contentType, byte[] content)
  2. addMimeHeader(SOAPMessage message, String name, String value)
  3. addNamespace(SOAPMessage message, String prefix, String uri)
  4. constructMessage(String mimeHdrsFile, String msgFile)
  5. convertSoapMessageToString(SOAPMessage message)