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

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

Introduction

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

Prototype

HandlerResolver

Source Link

Usage

From source file:com.moss.rpcutil.proxy.jaxws.JAXWSProxyProvider.java

public synchronized <T> T getProxy(Class<T> iface, String url) {

    QName type = registry.get(iface);

    if (type == null) {
        throw new RuntimeException("Service type not registered: " + iface);
    }/*from  w  w w .  j  a va 2 s. co m*/

    T proxy = (T) cache.get(url);
    if (proxy == null) {

        Service service;
        try {
            String wsdlLocation = url;
            if (!wsdlLocation.endsWith("?wsdl")) {
                wsdlLocation += "?wsdl";
            }
            service = Service.create(new URL(wsdlLocation), type);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }

        if (log.isDebugEnabled()) {
            // SOAP LOGGING STUFF
            service.setHandlerResolver(new HandlerResolver() {
                public List<Handler> getHandlerChain(PortInfo arg0) {
                    List<Handler> handlers = new LinkedList<Handler>();
                    handlers.add(new SOAPLoggingHandler(log));
                    return handlers;
                }
            });
        }

        proxy = service.getPort(iface);

        //         BindingProvider bp = (BindingProvider) proxy;
        //         
        //         bp.getRequestContext().put(
        //            MessageContext.HTTP_REQUEST_HEADERS, 
        //            Collections.singletonMap("Content-Type", Arrays.asList(new String[]{"application/soap+xml", "charset=utf-8"}))
        //         );

        cache.put(url, proxy);
    }

    return proxy;
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

public boolean checkConnection(final String url, final String login, final String password,
        final int customerId) throws VmsNotAvailableException {
    try {/*w  w w  .j av a2s . c  om*/
        LicenceService ss = new LicenceService();
        ss.setHandlerResolver(new HandlerResolver() {
            @SuppressWarnings("rawtypes")
            @Override
            public List<Handler> getHandlerChain(PortInfo portInfo) {
                List<Handler> handlerList = new ArrayList<Handler>();
                handlerList.add(new ViteroSecurityHandler(login, password));
                return handlerList;
            }

        });
        Licence port = ss.getLicenceSoap11();
        String endPoint = UriBuilder.fromUri(url).path("services").path("LicenseService").build().toString();
        ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
        GetModulesForCustomerRequest request = new GetModulesForCustomerRequest();
        request.setCustomerid(customerId);
        Modulestype modulesType = port.getModulesForCustomer(request);
        return modulesType != null;
    } catch (SOAPFaultException f) {
        ErrorCode code = handleAxisFault(f);
        switch (code) {
        case unsufficientRights:
            logError("Unsufficient rights", f);
            break;
        default:
            logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        logWarn("Error checking connection", e);
        return false;
    }
}