Search in sources :

Example 1 with DispatchImpl

use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.

the class DispatchTest method testFindOperationWithSource.

@Test
public void testFindOperationWithSource() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), serviceName, null);
    Dispatch<Source> disp = service.createDispatch(portName, Source.class, Service.Mode.MESSAGE);
    disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
    disp.getRequestContext().put("find.dispatch.operation", Boolean.TRUE);
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
    BindingOperationVerifier bov = new BindingOperationVerifier();
    ((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
    Document doc = StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
    DOMSource source = new DOMSource(doc);
    Source res = disp.invoke(source);
    assertNotNull(res);
    BindingOperationInfo boi = bov.getBindingOperationInfo();
    assertNotNull(boi);
    assertEquals(new QName("http://apache.org/hello_world_soap_http", "sayHi"), boi.getName());
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) QName(javax.xml.namespace.QName) Document(org.w3c.dom.Document) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with DispatchImpl

use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.

the class SymmetricBindingTest method testUsernameTokenSAML1Dispatch.

@org.junit.Test
public void testUsernameTokenSAML1Dispatch() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SymmetricBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SymmetricBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricSAML1Port");
    Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD, new AddressingFeature());
    updateAddressPort(dispatch, test.getPort());
    // Setup STSClient
    STSClient stsClient = createDispatchSTSClient(bus);
    String wsdlLocation = "http://localhost:" + test.getStsPort() + "/SecurityTokenService/UT?wsdl";
    stsClient.setWsdlLocation(wsdlLocation);
    // Creating a DOMSource Object for the request
    DOMSource request = createDOMRequest();
    // Make a successful request
    Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
    client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
    if (test.isStreaming()) {
        client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    DOMSource response = dispatch.invoke(request);
    assertNotNull(response);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) DOMSource(javax.xml.transform.dom.DOMSource) STSClient(org.apache.cxf.ws.security.trust.STSClient) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) AddressingFeature(javax.xml.ws.soap.AddressingFeature) QName(javax.xml.namespace.QName) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Service(javax.xml.ws.Service) STSClient(org.apache.cxf.ws.security.trust.STSClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Example 3 with DispatchImpl

use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.

the class TransportBindingTest method testSAML2DispatchLocation.

@org.junit.Test
public void testSAML2DispatchLocation() throws Exception {
    // Needed to prevent test failure using IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        System.setProperty("https.protocols", "TLSv1");
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = TransportBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = TransportBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
    Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
    updateAddressPort(dispatch, test.getPort());
    // Setup STSClient
    STSClient stsClient = createDispatchSTSClient(bus);
    String location = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport";
    stsClient.setLocation(location);
    stsClient.setPolicy("classpath:/org/apache/cxf/systest/sts/issuer/sts-transport-policy.xml");
    // Creating a DOMSource Object for the request
    DOMSource request = createDOMRequest();
    // Make a successful request
    Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
    client.getRequestContext().put(SecurityConstants.USERNAME, "alice");
    client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
    if (test.isStreaming()) {
        client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    DOMSource response = dispatch.invoke(request);
    assertNotNull(response);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) DOMSource(javax.xml.transform.dom.DOMSource) STSClient(org.apache.cxf.ws.security.trust.STSClient) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Service(javax.xml.ws.Service) STSClient(org.apache.cxf.ws.security.trust.STSClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Example 4 with DispatchImpl

use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.

the class TransportBindingTest method testSAML2Dispatch.

@org.junit.Test
public void testSAML2Dispatch() throws Exception {
    // Needed to prevent test failure using IBM JDK
    if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
        System.setProperty("https.protocols", "TLSv1");
    }
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = TransportBindingTest.class.getResource("cxf-client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = TransportBindingTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
    Dispatch<DOMSource> dispatch = service.createDispatch(portQName, DOMSource.class, Service.Mode.PAYLOAD);
    updateAddressPort(dispatch, test.getPort());
    // Setup STSClient
    STSClient stsClient = createDispatchSTSClient(bus);
    String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
    stsClient.setWsdlLocation(wsdlLocation);
    // Creating a DOMSource Object for the request
    DOMSource request = createDOMRequest();
    // Make a successful request
    Client client = ((DispatchImpl<DOMSource>) dispatch).getClient();
    client.getRequestContext().put(SecurityConstants.USERNAME, "alice");
    client.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
    if (test.isStreaming()) {
        client.getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
        client.getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
    }
    DOMSource response = dispatch.invoke(request);
    assertNotNull(response);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) DOMSource(javax.xml.transform.dom.DOMSource) STSClient(org.apache.cxf.ws.security.trust.STSClient) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) Service(javax.xml.ws.Service) STSClient(org.apache.cxf.ws.security.trust.STSClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL)

Example 5 with DispatchImpl

use of org.apache.cxf.jaxws.DispatchImpl in project cxf by apache.

the class ClientServerTest method testEchoProviderAsyncDecoupledEndpoints.

@Test
public void testEchoProviderAsyncDecoupledEndpoints() throws Exception {
    String requestString = "<echo/>";
    Service service = Service.create(serviceName);
    service.addPort(fakePortName, javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:" + PORT + "/SoapContext/AsyncEchoProvider");
    Dispatch<StreamSource> dispatcher = service.createDispatch(fakePortName, StreamSource.class, Service.Mode.PAYLOAD);
    Client client = ((DispatchImpl<StreamSource>) dispatcher).getClient();
    WSAddressingFeature wsAddressingFeature = new WSAddressingFeature();
    wsAddressingFeature.initialize(client, client.getBus());
    dispatcher.getRequestContext().put("org.apache.cxf.ws.addressing.replyto", "http://localhost:" + CLIENT_PORT + "/SoapContext/AsyncEchoClient");
    StreamSource request = new StreamSource(new ByteArrayInputStream(requestString.getBytes()));
    StreamSource response = dispatcher.invoke(request);
    assertEquals(requestString, StaxUtils.toString(response));
}
Also used : WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) StreamSource(javax.xml.transform.stream.StreamSource) SOAPService(org.apache.hello_world_soap_http.SOAPService) Service(javax.xml.ws.Service) ExecutorService(java.util.concurrent.ExecutorService) Client(org.apache.cxf.endpoint.Client) SOAPServiceMultiPortTypeTest(org.apache.hello_world_soap_http.SOAPServiceMultiPortTypeTest) SOAPServiceBogusAddressTest(org.apache.hello_world_soap_http.SOAPServiceBogusAddressTest) Test(org.junit.Test)

Aggregations

DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)24 Client (org.apache.cxf.endpoint.Client)18 QName (javax.xml.namespace.QName)12 Service (javax.xml.ws.Service)12 URL (java.net.URL)10 Bus (org.apache.cxf.Bus)9 DOMSource (javax.xml.transform.dom.DOMSource)8 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)7 Document (org.w3c.dom.Document)7 Test (org.junit.Test)6 Source (javax.xml.transform.Source)5 StreamSource (javax.xml.transform.stream.StreamSource)5 AddressingFeature (javax.xml.ws.soap.AddressingFeature)4 STSClient (org.apache.cxf.ws.security.trust.STSClient)4 HashMap (java.util.HashMap)3 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)3 MessageReplayObserver (org.apache.cxf.jaxws.MessageReplayObserver)3 ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3