Search in sources :

Example 1 with PortInfo

use of javax.xml.ws.handler.PortInfo in project nhin-d by DirectProject.

the class DirectSOAPHandlerResolverTest method testGetHandlerChain.

/**
     * Test the getHandlerChain method.
     */
public void testGetHandlerChain() {
    PortInfo portInfo = null;
    List<Handler> output = null;
    DirectSOAPHandlerResolver handler = new DirectSOAPHandlerResolver();
    output = handler.getHandlerChain(portInfo);
    assertNotNull("List is null", output);
    assertTrue("List contains 0 elements", !output.isEmpty());
    assertEquals("List contains more than expected elements", 1, output.size());
    assertTrue("List does not contain expected element", output.get(0) instanceof DirectSOAPHandler);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) Handler(javax.xml.ws.handler.Handler)

Example 2 with PortInfo

use of javax.xml.ws.handler.PortInfo in project scout.rt by eclipse.

the class PortProducer method provide.

/**
 * Creates a new Port to interact with the webservice endpoint.
 */
@Override
public PORT provide() {
    try {
        // Create the service
        final Constructor<? extends Service> constructor = m_serviceClazz.getConstructor(URL.class, QName.class);
        @SuppressWarnings("unchecked") final SERVICE service = (SERVICE) constructor.newInstance(m_wsdlLocation, new QName(m_targetNamespace, m_serviceName));
        // Install the handler chain
        service.setHandlerResolver(new HandlerResolver() {

            @Override
            public List<Handler> getHandlerChain(final PortInfo portInfo) {
                final List<Handler<? extends MessageContext>> handlerChain = new ArrayList<>();
                m_initializer.initHandlers(handlerChain);
                for (int i = 0; i < handlerChain.size(); i++) {
                    handlerChain.set(i, proxyHandler(handlerChain.get(i)));
                }
                @SuppressWarnings("unchecked") final List<Handler> handlers = TypeCastUtility.castValue(handlerChain, List.class);
                return handlers;
            }
        });
        // Install implementor specific webservice features
        final List<WebServiceFeature> webServiceFeatures = new ArrayList<>();
        m_initializer.initWebServiceFeatures(webServiceFeatures);
        // Create the port
        return service.getPort(m_portTypeClazz, CollectionUtility.toArray(webServiceFeatures, WebServiceFeature.class));
    } catch (final ReflectiveOperationException e) {
        throw new WebServiceException("Failed to instantiate webservice stub.", e);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) WebServiceFeature(javax.xml.ws.WebServiceFeature) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with PortInfo

use of javax.xml.ws.handler.PortInfo in project scout.rt by eclipse.

the class ServicePool method createElement.

@Override
protected SERVICE createElement() {
    try {
        // Create the service
        final Constructor<? extends Service> constructor = m_serviceClazz.getConstructor(URL.class, QName.class);
        @SuppressWarnings("unchecked") final SERVICE service = (SERVICE) constructor.newInstance(m_wsdlLocation, new QName(m_targetNamespace, m_serviceName));
        // Install the handler chain
        service.setHandlerResolver(new HandlerResolver() {

            @Override
            public List<Handler> getHandlerChain(final PortInfo portInfo) {
                final List<Handler<? extends MessageContext>> handlerChain = new ArrayList<>();
                m_initializer.initHandlers(handlerChain);
                for (int i = 0; i < handlerChain.size(); i++) {
                    handlerChain.set(i, proxyHandler(handlerChain.get(i)));
                }
                @SuppressWarnings("unchecked") final List<Handler> handlers = TypeCastUtility.castValue(handlerChain, List.class);
                return handlers;
            }
        });
        return service;
    } catch (ReflectiveOperationException e) {
        throw new WebServiceException("Failed to instantiate webservice stub.", e);
    }
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with PortInfo

use of javax.xml.ws.handler.PortInfo in project jbossws-cxf by jbossws.

the class HandlerChainClient method testService1.

public String testService1(String reqStr) throws Exception {
    PortInfo info = new PortInfo() {

        @Override
        public String getBindingID() {
            return "http://schemas.xmlsoap.org/wsdl/soap/http";
        }

        @Override
        public QName getPortName() {
            return null;
        }

        @Override
        public QName getServiceName() {
            return null;
        }
    };
    HandlerResolver resolver = service1.getHandlerResolver();
    @SuppressWarnings("rawtypes") List<Handler> handlerChain = resolver.getHandlerChain(info);
    if ("[LogHandler, AuthorizationHandler, RoutingHandler, MimeHandler]".equals(handlerChain.toString()) == false)
        throw new IllegalStateException("Unexpected resolver handlers: " + handlerChain);
    Endpoint port = service1.getPort(Endpoint.class);
    return port.echo(reqStr);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) Handler(javax.xml.ws.handler.Handler)

Example 5 with PortInfo

use of javax.xml.ws.handler.PortInfo in project openolat by klemens.

the class ViteroManager method checkConnection.

public boolean checkConnection(final String url, final String login, final String password, final int customerId) throws VmsNotAvailableException {
    try {
        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:
                log.error("Unsufficient rights", f);
                break;
            default:
                logAxisError("Cannot check connection", f);
        }
        return false;
    } catch (WebServiceException e) {
        if (e.getCause() instanceof ConnectException) {
            throw new VmsNotAvailableException();
        }
        log.warn("Error checking connection", e);
        return false;
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Handler(javax.xml.ws.handler.Handler) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) DataHandler(javax.activation.DataHandler) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Modulestype(de.vitero.schema.licence.Modulestype) PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) GetModulesForCustomerRequest(de.vitero.schema.licence.GetModulesForCustomerRequest) Licence(de.vitero.schema.licence.Licence) ArrayList(java.util.ArrayList) List(java.util.List) ErrorCode(org.olat.modules.vitero.model.ErrorCode) ViteroSecurityHandler(de.vitero.ViteroSecurityHandler) LicenceService(de.vitero.schema.licence.LicenceService) ConnectException(java.net.ConnectException)

Aggregations

PortInfo (javax.xml.ws.handler.PortInfo)9 Handler (javax.xml.ws.handler.Handler)6 HandlerResolver (javax.xml.ws.handler.HandlerResolver)6 ArrayList (java.util.ArrayList)5 List (java.util.List)4 WebServiceException (javax.xml.ws.WebServiceException)4 ViteroSecurityHandler (de.vitero.ViteroSecurityHandler)2 GetModulesForCustomerRequest (de.vitero.schema.licence.GetModulesForCustomerRequest)2 Licence (de.vitero.schema.licence.Licence)2 LicenceService (de.vitero.schema.licence.LicenceService)2 Modulestype (de.vitero.schema.licence.Modulestype)2 ConnectException (java.net.ConnectException)2 DataHandler (javax.activation.DataHandler)2 QName (javax.xml.namespace.QName)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 ErrorCode (org.olat.modules.vitero.model.ErrorCode)2 URI (java.net.URI)1 URL (java.net.URL)1 BindingProvider (javax.xml.ws.BindingProvider)1 WebServiceFeature (javax.xml.ws.WebServiceFeature)1