Search in sources :

Example 6 with PortInfo

use of javax.xml.ws.handler.PortInfo in project Payara by payara.

the class HandlerResolverImpl method getHandlerChain.

public List<Handler> getHandlerChain(PortInfo info) {
    Iterator<PortInfo> piSet = chainMap.keySet().iterator();
    List<Handler> chain = null;
    while (piSet.hasNext()) {
        PortInfo next = piSet.next();
        PortInfoImpl tmp = new PortInfoImpl(BindingID.parse(info.getBindingID()), info.getPortName(), info.getServiceName());
        if (tmp.equals(next)) {
            chain = chainMap.get(next);
            break;
        }
    }
    if (chain == null) {
        chain = new ArrayList<Handler>();
    }
    return chain;
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) Handler(javax.xml.ws.handler.Handler)

Example 7 with PortInfo

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

the class ServiceImplTest method testHandlerResolver.

@Test
public void testHandlerResolver() {
    URL wsdl1 = getClass().getResource("/wsdl/calculator.wsdl");
    assertNotNull(wsdl1);
    ServiceImpl service = new ServiceImpl(getBus(), wsdl1, SERVICE_1, ServiceImpl.class);
    TestHandlerResolver resolver = new TestHandlerResolver();
    assertNull(resolver.getPortInfo());
    service.setHandlerResolver(resolver);
    CalculatorPortType cal = service.getPort(PORT_1, CalculatorPortType.class);
    assertNotNull(cal);
    PortInfo info = resolver.getPortInfo();
    assertNotNull(info);
    assertEquals(SERVICE_1, info.getServiceName());
    assertEquals(PORT_1, info.getPortName());
    assertEquals(SOAPBinding.SOAP12HTTP_BINDING, info.getBindingID());
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) CalculatorPortType(org.apache.cxf.calculator.CalculatorPortType) URL(java.net.URL) Test(org.junit.Test)

Example 8 with PortInfo

use of javax.xml.ws.handler.PortInfo in project OpenOLAT by OpenOLAT.

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)

Example 9 with PortInfo

use of javax.xml.ws.handler.PortInfo in project cloudstack by apache.

the class VmwareClient method pbmConnect.

private void pbmConnect(String url, String cookieValue) throws Exception {
    URI uri = new URI(url);
    String pbmurl = "https://" + uri.getHost() + "/pbm";
    String[] tokens = cookieValue.split("=");
    String extractedCookie = tokens[1];
    HandlerResolver soapHandlerResolver = new HandlerResolver() {

        @Override
        public List<Handler> getHandlerChain(PortInfo portInfo) {
            VcenterSessionHandler VcSessionHandler = new VcenterSessionHandler(extractedCookie);
            List<Handler> handlerChain = new ArrayList<Handler>();
            handlerChain.add((Handler) VcSessionHandler);
            return handlerChain;
        }
    };
    pbmService.setHandlerResolver(soapHandlerResolver);
    pbmSvcInstRef.setType(PBM_SERVICE_INSTANCE_TYPE);
    pbmSvcInstRef.setValue(PBM_SERVICE_INSTANCE_VALUE);
    pbmPort = pbmService.getPbmPort();
    Map<String, Object> pbmCtxt = ((BindingProvider) pbmPort).getRequestContext();
    pbmCtxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
    pbmCtxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pbmurl);
}
Also used : PortInfo(javax.xml.ws.handler.PortInfo) HandlerResolver(javax.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) Handler(javax.xml.ws.handler.Handler) BindingProvider(javax.xml.ws.BindingProvider) URI(java.net.URI)

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