javax.xml.ws.soap.SOAPBinding Java Examples

The following examples show how to use javax.xml.ws.soap.SOAPBinding. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceImplTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@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());
}
 
Example #2
Source File: HandlerConfigurator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
 
Example #3
Source File: HandlerConfigurator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
 
Example #4
Source File: DeploymentDescriptorParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
 
Example #5
Source File: HandlerConfigurator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
 
Example #6
Source File: DeploymentDescriptorParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
 
Example #7
Source File: ClientMtomXopWithJMSTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void startServers() throws Exception {
    Object implementor = new TestMtomJMSImpl();
    bus = BusFactory.getDefaultBus();

    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
    cff = new ConnectionFactoryFeature(cfp);

    EndpointImpl ep = (EndpointImpl)Endpoint.create(implementor);
    ep.getFeatures().add(cff);
    ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
    ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
    //ep.getInInterceptors().add(new LoggingInInterceptor());
    //ep.getOutInterceptors().add(new LoggingOutInterceptor());
    SOAPBinding jaxWsSoapBinding = (SOAPBinding)ep.getBinding();
    jaxWsSoapBinding.setMTOMEnabled(true);
    ep.publish();
}
 
Example #8
Source File: HandlerConfigurator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
void configureHandlers(WSPortInfo port, BindingImpl binding) {
    //Check in cache first
    HandlerAnnotationInfo chain = chainMap.get(port);

    if(chain==null) {
        logGetChain(port);
        // Put it in cache
        chain = handlerModel.getHandlersForPortInfo(port);
        chainMap.put(port,chain);
    }

    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(chain.getRoles());
    }

    logSetChain(port,chain);
    binding.setHandlerChain(chain.getHandlers());
}
 
Example #9
Source File: DeploymentDescriptorParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses the handler and role information and sets it
 * on the {@link WSBinding}.
 *
 * @return true if <handler-chains> element present in DD
 *         false otherwise.
 */
protected boolean setHandlersAndRoles(WSBinding binding, XMLStreamReader reader, QName serviceName, QName portName) {

    if (reader.getEventType() == XMLStreamConstants.END_ELEMENT ||
            !reader.getName().equals(HandlerChainsModel.QNAME_HANDLER_CHAINS)) {
        return false;
    }

    HandlerAnnotationInfo handlerInfo = HandlerChainsModel.parseHandlerFile(
            reader, classLoader, serviceName, portName, binding);

    binding.setHandlerChain(handlerInfo.getHandlers());
    if (binding instanceof SOAPBinding) {
        ((SOAPBinding) binding).setRoles(handlerInfo.getRoles());
    }

    // move past </handler-chains>
    XMLStreamReaderUtil.nextContent(reader);
    return true;
}
 
Example #10
Source File: JMSTestMtom.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testMTOM() throws Exception {
    QName serviceName = new QName("http://cxf.apache.org/jms_mtom", "JMSMTOMService");
    QName portName = new QName("http://cxf.apache.org/jms_mtom", "MTOMPort");

    URL wsdl = getWSDLURL("/wsdl/jms_test_mtom.wsdl");
    JMSMTOMService service = new JMSMTOMService(wsdl, serviceName);

    JMSMTOMPortType mtom = service.getPort(portName, JMSMTOMPortType.class);
    Binding binding = ((BindingProvider)mtom).getBinding();
    ((SOAPBinding)binding).setMTOMEnabled(true);

    Holder<String> name = new Holder<>("Sam");
    URL fileURL = this.getClass().getResource("/org/apache/cxf/systest/jms/JMSClientServerTest.class");
    Holder<DataHandler> handler1 = new Holder<>();
    handler1.value = new DataHandler(fileURL);
    int size = handler1.value.getInputStream().available();
    mtom.testDataHandler(name, handler1);

    byte[] bytes = IOUtils.readBytesFromStream(handler1.value.getInputStream());
    Assert.assertEquals("The response file is not same with the sent file.", size, bytes.length);
    ((Closeable)mtom).close();
}
 
Example #11
Source File: ClientServerMiscTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testDocLitWrappedCodeFirstServiceNoWsdlNoASM() throws Exception {
    try {
        setASM(false);
        QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
                                   "DocLitWrappedCodeFirstServicePort");
        QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService",
                                   "DocLitWrappedCodeFirstService");

        Service service = Service.create(servName);
        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, ServerMisc.DOCLIT_CODEFIRST_URL);
        DocLitWrappedCodeFirstService port = service.getPort(portName,
                                                             DocLitWrappedCodeFirstService.class);
        runDocLitTest(port);
    } finally {
        setASM(true);
    }
}
 
Example #12
Source File: EndpointFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> void processHandlerAnnotation(WSBinding binding, Class<T> implType, QName serviceName, QName portName) {
    HandlerAnnotationInfo chainInfo =
            HandlerAnnotationProcessor.buildHandlerInfo(
                    implType, serviceName, portName, binding);
    if (chainInfo != null) {
        binding.setHandlerChain(chainInfo.getHandlers());
        if (binding instanceof SOAPBinding) {
            ((SOAPBinding) binding).setRoles(chainInfo.getRoles());
        }
    }

}
 
Example #13
Source File: JaxWsClient.java    From spring-boot-cxf-integration-example with MIT License 5 votes vote down vote up
/**
 * Loads the content with the specified name from the WebService
 * 
 * @param name The name of the content
 * @return The loaded content
 * @throws IOException If an IO error occurs
 */
public DataHandler loadContent(String name) throws IOException {
    ContentStoreHttpPortService service = new ContentStoreHttpPortService();
    ContentStoreHttpPort loadContentPort = service.getContentStoreHttpPortSoap11();
    SOAPBinding binding = (SOAPBinding) ((BindingProvider) loadContentPort).getBinding();
    binding.setMTOMEnabled(true);

    LoadContentRequest request = objectFactory.createLoadContentRequest();
    request.setName(name);
    LoadContentResponse response = loadContentPort.loadContent(request);
    DataHandler content = response.getContent();
    return content;
}
 
Example #14
Source File: ClientTubeAssemblerContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that invokes protocol and logical handlers.
 */
public Tube createHandlerTube(Tube next) {
    HandlerTube cousinHandlerTube = null;
    //XML/HTTP Binding can have only LogicalHandlerPipe
    if (binding instanceof SOAPBinding) {
        //Add MessageHandlerTube
        HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
        next = cousinHandlerTube = messageHandlerTube;

        //Add SOAPHandlerTuber
        HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
        next = cousinHandlerTube = soapHandlerTube;
    }
    return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
}
 
Example #15
Source File: ServerTubeAssemblerContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * creates a {@link Tube} that validates messages against schema
 */
public Tube createValidationTube(Tube next) {
    if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
        return new ServerSchemaValidationTube(endpoint, binding, seiModel, wsdlModel, next);
    else
        return next;
}
 
Example #16
Source File: DeploymentDescriptorParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * JSR-109 defines short-form tokens for standard binding Ids. These are
 * used only in DD. So stand alone deployment descirptor should also honor
 * these tokens. This method converts the tokens to API's standard
 * binding ids
 *
 * @param lexical binding attribute value from DD. Always not null
 * @return returns corresponding API's binding ID or the same lexical
 */
public static @NotNull String getBindingIdForToken(@NotNull String lexical) {
    if (lexical.equals("##SOAP11_HTTP")) {
        return SOAPBinding.SOAP11HTTP_BINDING;
    } else if (lexical.equals("##SOAP11_HTTP_MTOM")) {
        return SOAPBinding.SOAP11HTTP_MTOM_BINDING;
    } else if (lexical.equals("##SOAP12_HTTP")) {
        return SOAPBinding.SOAP12HTTP_BINDING;
    } else if (lexical.equals("##SOAP12_HTTP_MTOM")) {
        return SOAPBinding.SOAP12HTTP_MTOM_BINDING;
    } else if (lexical.equals("##XML_HTTP")) {
        return HTTPBinding.HTTP_BINDING;
    }
    return lexical;
}
 
Example #17
Source File: CalculatorTest.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void testCalculatorViaWsInterfaceWithSign() throws Exception {
    final Service calcService = Service.create(new URL("http://localhost:" + port + "/webservice-ws-security/CalculatorImplSign?wsdl"),
            new QName("http://superbiz.org/wsdl", "CalculatorWsService"));
    assertNotNull(calcService);

    // for debugging (ie. TCPMon)
    calcService.addPort(new QName("http://superbiz.org/wsdl",
                    "CalculatorWsService2"), SOAPBinding.SOAP12HTTP_BINDING,
            "http://127.0.0.1:8204/CalculatorImplSign");

    //      CalculatorWs calc = calcService.getPort(
    //	new QName("http://superbiz.org/wsdl", "CalculatorWsService2"),
    //	CalculatorWs.class);

    final CalculatorWs calc = calcService.getPort(CalculatorWs.class);

    final Client client = ClientProxy.getClient(calc);
    final Endpoint endpoint = client.getEndpoint();
    endpoint.getOutInterceptors().add(new SAAJOutInterceptor());

    final Map<String, Object> outProps = new HashMap<String, Object>();
    outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE);
    outProps.put(WSHandlerConstants.USER, "clientalias");
    outProps.put(WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {

        @Override
        public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
            pc.setPassword("clientPassword");
        }
    });
    outProps.put(WSHandlerConstants.SIG_PROP_FILE, "META-INF/CalculatorImplSign-client.properties");
    outProps.put(WSHandlerConstants.SIG_KEY_ID, "IssuerSerial");

    final WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
    endpoint.getOutInterceptors().add(wssOut);

    assertEquals(24, calc.multiply(4, 6));
}
 
Example #18
Source File: ClientTubeAssemblerContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that invokes protocol and logical handlers.
 */
public Tube createHandlerTube(Tube next) {
    HandlerTube cousinHandlerTube = null;
    //XML/HTTP Binding can have only LogicalHandlerPipe
    if (binding instanceof SOAPBinding) {
        //Add MessageHandlerTube
        HandlerTube messageHandlerTube = new ClientMessageHandlerTube(seiModel, binding, wsdlModel, next);
        next = cousinHandlerTube = messageHandlerTube;

        //Add SOAPHandlerTuber
        HandlerTube soapHandlerTube = new ClientSOAPHandlerTube(binding, next, cousinHandlerTube);
        next = cousinHandlerTube = soapHandlerTube;
    }
    return new ClientLogicalHandlerTube(binding, seiModel, next, cousinHandlerTube);
}
 
Example #19
Source File: EndpointFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static <T> void processHandlerAnnotation(WSBinding binding, Class<T> implType, QName serviceName, QName portName) {
    HandlerAnnotationInfo chainInfo =
            HandlerAnnotationProcessor.buildHandlerInfo(
                    implType, serviceName, portName, binding);
    if (chainInfo != null) {
        binding.setHandlerChain(chainInfo.getHandlers());
        if (binding instanceof SOAPBinding) {
            ((SOAPBinding) binding).setRoles(chainInfo.getRoles());
        }
    }

}
 
Example #20
Source File: DispatchSourceClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        Server.main(new String[]{"inProcess"});

        Service service = Service.create(SERVICE_NAME);
        service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, ADDRESS);

        Dispatch<Source> dispatch = service.createDispatch(PORT_NAME, Source.class, Service.Mode.PAYLOAD);

        String resp;
        Source response;

        System.out.println("Invoking sayHi...");
        setOperation(dispatch, SAYHI_OPERATION_NAME);
        response = dispatch.invoke(encodeSource(SAYHI_REQUEST_TEMPLATE, null));
        resp = decodeSource(response, PAYLOAD_NAMESPACE_URI, "responseType");
        System.out.println("Server responded with: " + resp);
        System.out.println();

        System.out.println("Invoking greetMe...");
        setOperation(dispatch, GREETME_OPERATION_NAME);
        response = dispatch.invoke(encodeSource(GREETME_REQUEST_TEMPLATE, System.getProperty("user.name")));
        resp = decodeSource(response, PAYLOAD_NAMESPACE_URI, "responseType");
        System.out.println("Server responded with: " + resp);
        System.out.println();

        try {
            System.out.println("Invoking pingMe, expecting exception...");
            setOperation(dispatch, PINGME_OPERATION_NAME);
            response = dispatch.invoke(encodeSource(PINGME_REQUEST_TEMPLATE, null));
        } catch (SOAPFaultException ex) {
            System.out.println("Expected exception: SoapFault has occurred: " + ex.getMessage());
        }
        System.exit(0);
    }
 
Example #21
Source File: ServerTubeAssemblerContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * creates a {@link Tube} that validates messages against schema
 */
public Tube createValidationTube(Tube next) {
    if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
        return new ServerSchemaValidationTube(endpoint, binding, seiModel, wsdlModel, next);
    else
        return next;
}
 
Example #22
Source File: ServerTubeAssemblerContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * creates a {@link Tube} that validates messages against schema
 */
public Tube createValidationTube(Tube next) {
    if (binding instanceof SOAPBinding && binding.isFeatureEnabled(SchemaValidationFeature.class) && wsdlModel!=null)
        return new ServerSchemaValidationTube(endpoint, binding, seiModel, wsdlModel, next);
    else
        return next;
}
 
Example #23
Source File: ServerTubeAssemblerContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that performs SOAP mustUnderstand processing.
 * This pipe should be before HandlerPipes.
 */
public @NotNull Tube createServerMUTube(@NotNull Tube next) {
    if (binding instanceof SOAPBinding)
        return new ServerMUTube(this,next);
    else
        return next;
}
 
Example #24
Source File: EndpointFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static <T> void processHandlerAnnotation(WSBinding binding, Class<T> implType, QName serviceName, QName portName) {
    HandlerAnnotationInfo chainInfo =
            HandlerAnnotationProcessor.buildHandlerInfo(
                    implType, serviceName, portName, binding);
    if (chainInfo != null) {
        binding.setHandlerChain(chainInfo.getHandlers());
        if (binding instanceof SOAPBinding) {
            ((SOAPBinding) binding).setRoles(chainInfo.getRoles());
        }
    }

}
 
Example #25
Source File: HttpTransportPipe.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void checkStatusCode(InputStream in, HttpClientTransport con) throws IOException {
    int statusCode = con.statusCode;
    String statusMessage = con.statusMessage;
    // SOAP1.1 and SOAP1.2 differ here
    if (binding instanceof SOAPBinding) {
        if (binding.getSOAPVersion() == SOAPVersion.SOAP_12) {
            //In SOAP 1.2, Fault messages can be sent with 4xx and 5xx error codes
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || isErrorCode(statusCode)) {
                // acceptable status codes for SOAP 1.2
                if (isErrorCode(statusCode) && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        } else {
            // SOAP 1.1
            if (statusCode == HttpURLConnection.HTTP_OK || statusCode == HttpURLConnection.HTTP_ACCEPTED || statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
                // acceptable status codes for SOAP 1.1
                if (statusCode == HttpURLConnection.HTTP_INTERNAL_ERROR && in == null) {
                    // No envelope for the error, so throw an exception with http error details
                    throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
                }
                return;
            }
        }
        if (in != null) {
            in.close();
        }
        throw new ClientTransportException(ClientMessages.localizableHTTP_STATUS_CODE(statusCode, statusMessage));
    }
    // Every status code is OK for XML/HTTP
}
 
Example #26
Source File: WSSecurityClientTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static Dispatch<Source> createUsernameTokenDispatcher(boolean decoupled, String port) {
    final Service service = Service.create(
        GREETER_SERVICE_QNAME
    );
    service.addPort(
        USERNAME_TOKEN_PORT_QNAME,
        decoupled ? SOAPBinding.SOAP11HTTP_BINDING : HTTPBinding.HTTP_BINDING,
        "http://localhost:" + port + "/GreeterService/UsernameTokenPort"
    );
    final Dispatch<Source> dispatcher = service.createDispatch(
        USERNAME_TOKEN_PORT_QNAME,
        Source.class,
        Service.Mode.MESSAGE,
        new AddressingFeature(decoupled, decoupled)
    );
    final java.util.Map<String, Object> requestContext =
        dispatcher.getRequestContext();
    requestContext.put(
        MessageContext.HTTP_REQUEST_METHOD,
        "POST"
    );
    if (decoupled) {
        HTTPConduit cond = (HTTPConduit)((DispatchImpl<?>)dispatcher).getClient().getConduit();
        cond.getClient().setDecoupledEndpoint("http://localhost:" + DEC_PORT + "/decoupled");
    }
    return dispatcher;
}
 
Example #27
Source File: ClientTubeAssemblerContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a {@link Tube} that invokes protocol and logical handlers.
 */
public Tube createWsaTube(Tube next) {
    if (binding instanceof SOAPBinding && AddressingVersion.isEnabled(binding) && wsdlModel!=null)
        if(AddressingVersion.fromBinding(binding) == AddressingVersion.MEMBER) {
            return new MemberSubmissionWsaClientTube(wsdlModel, binding, next);
        } else {
            return new W3CWsaClientTube(wsdlModel, binding, next);
        }
    else
        return next;
}
 
Example #28
Source File: JaxWsServiceFactoryBeanTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMtomFeature() throws Exception {
    JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    bean.setBus(getBus());
    bean.setServiceClass(GreeterImpl.class);
    bean.setWsdlURL(getClass().getResource("/wsdl/hello_world.wsdl"));
    bean.setWsFeatures(Arrays.asList(new WebServiceFeature[]{new MTOMFeature()}));
    Service service = bean.create();
    Endpoint endpoint = service.getEndpoints().values().iterator().next();
    assertTrue(endpoint instanceof JaxWsEndpointImpl);
    Binding binding = ((JaxWsEndpointImpl)endpoint).getJaxwsBinding();
    assertTrue(binding instanceof SOAPBinding);
    assertTrue(((SOAPBinding)binding).isMTOMEnabled());
}
 
Example #29
Source File: JaxWsProviderWrapper.java    From tomee with Apache License 2.0 5 votes vote down vote up
private void setProperties(final BindingProvider proxy, final QName qname) {
    for (final PortRefMetaData portRef : portRefs) {
        Class<?> intf = null;
        if (portRef.getServiceEndpointInterface() != null) {
            try {
                intf = proxy.getClass().getClassLoader().loadClass(portRef.getServiceEndpointInterface());
            } catch (ClassNotFoundException e) {
                logger.log(Level.INFO, "Not loading: " + portRef.getServiceEndpointInterface());
            }
        }
        if ((qname != null && qname.equals(portRef.getQName())) || (intf != null && intf.isInstance(proxy))) {
            // set address
            if (!portRef.getAddresses().isEmpty()) {
                proxy.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, portRef.getAddresses().get(0));
            }

            // set mtom
            final boolean enableMTOM = portRef.isEnableMtom();
            if (enableMTOM && proxy.getBinding() instanceof SOAPBinding) {
                ((SOAPBinding) proxy.getBinding()).setMTOMEnabled(enableMTOM);
            }

            // set properties
            for (final Map.Entry<Object, Object> entry : portRef.getProperties().entrySet()) {
                final String name = (String) entry.getKey();
                final String value = (String) entry.getValue();
                proxy.getRequestContext().put(name, value);
            }

            return;
        }
    }
}
 
Example #30
Source File: BindingID.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static String getJaxwsBindingID(String transportID) {
    if (SoapTransportFactory.SOAP_11_HTTP_BINDING.equals(transportID)) {
        return SOAPBinding.SOAP11HTTP_BINDING;
    } else if (SoapTransportFactory.SOAP_12_HTTP_BINDING.equals(transportID)) {
        return SOAPBinding.SOAP12HTTP_BINDING;
    } else {
        return transportID;
    }
}