Example usage for javax.xml.ws.handler HandlerResolver getHandlerChain

List of usage examples for javax.xml.ws.handler HandlerResolver getHandlerChain

Introduction

In this page you can find the example usage for javax.xml.ws.handler HandlerResolver getHandlerChain.

Prototype

public java.util.List<Handler> getHandlerChain(PortInfo portInfo);

Source Link

Document

Gets the handler chain for the specified port.

Usage

From source file:org.apache.axis2.jaxws.BindingProvider.java

private void initialize(org.apache.axis2.addressing.EndpointReference epr, String addressingNamespace,
        WebServiceFeature... features) {
    requestContext = new ValidatingClientContext();
    responseContext = new ValidatingClientContext();

    // Setting standard property defaults for the request context
    requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.FALSE);
    requestContext.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);

    // Addressing is disabled by default unless it is turned on in the WSDL
    String addressingFlagFromWSDL = AddressingHelper
            .getAddressingRequirementParemeterValue(endpointDesc.getAxisService());
    if (AddressingConstants.ADDRESSING_UNSPECIFIED.equals(addressingFlagFromWSDL)) {
        requestContext.put(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
    }//  ww  w.jav  a 2  s.  c o  m

    // Set the endpoint address
    String endpointAddress = (epr != null) ? epr.getAddress() : endpointDesc.getEndpointAddress();
    if (endpointAddress != null && !"".equals(endpointAddress)) {
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
    }

    // JAXWS 9.2.1.1 requires that we go ahead and create the binding object
    // so we can also set the handlerchain
    binding = (org.apache.axis2.jaxws.spi.Binding) BindingUtils.createBinding(endpointDesc);
    if (log.isDebugEnabled()) {
        log.debug("Lookign for Handler Resolver");
    }
    // TODO should we allow the ServiceDelegate to figure out the default handlerresolver?  Probably yes, since a client app may look for one there.
    HandlerResolver handlerResolver = null;
    if (serviceDelegate.getHandlerResolver() != null) {
        if (log.isDebugEnabled()) {
            log.debug("Reading default Handler Resolver ");
        }
        handlerResolver = serviceDelegate.getHandlerResolver();
    } else {
        handlerResolver = new HandlerResolverImpl(endpointDesc.getServiceDescription(), serviceDelegate);
        if (log.isDebugEnabled()) {
            log.debug("Creating new Handler Resolver using HandlerResolverImpl");
        }
    }

    // See if the metadata from creating the service indicates that MTOM, Addressing and/or RespectBinding should be enabled
    if (binding instanceof SOAPBinding) {
        configureBindingFromMetadata();
    }

    // check for properties that need to be set on the BindingProvider
    String seiName = null;
    if (endpointDesc.getEndpointInterfaceDescription() != null
            && endpointDesc.getEndpointInterfaceDescription().getSEIClass() != null) {
        seiName = endpointDesc.getEndpointInterfaceDescription().getSEIClass().getName();
    }
    String portQNameString = endpointDesc.getPortQName().toString();
    String key = seiName + ":" + portQNameString;
    Map<String, Object> bProps = endpointDesc.getServiceDescription().getBindingProperties(serviceDelegate,
            key);
    if (bProps != null) {
        if (log.isDebugEnabled()) {
            log.debug("Setting binding props with size: " + bProps.size() + " on "
                    + "BindingProvider RequestContext");
        }
        requestContext.putAll(bProps);
    }

    binding.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));

    //Set JAX-WS 2.1 related properties.
    try {
        binding.setAxis2EndpointReference(epr);
        binding.setAddressingNamespace(addressingNamespace);
        binding.setFeatures(features);
    } catch (Exception e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
}