Search in sources :

Example 11 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class FastInfosetTestCase method internalTestInfosetUsingFeatureProperties.

private void internalTestInfosetUsingFeatureProperties(URL wsdlURL, QName serviceName, QName portQName) throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ByteArrayOutputStream in = new ByteArrayOutputStream();
    PrintWriter pwIn = new PrintWriter(in);
    PrintWriter pwOut = new PrintWriter(out);
    Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        bus.getInInterceptors().add(new LoggingInInterceptor(pwIn));
        bus.getOutInterceptors().add(new LoggingOutInterceptor(pwOut));
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        HelloWorld port = (HelloWorld) service.getPort(portQName, HelloWorld.class);
        ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
        configurer.setConfigProperties(port, "META-INF/jaxws-client-config.xml", "Custom Client Config");
        assertEquals("helloworld", port.echo("helloworld"));
        assertTrue("request is expected fastinfoset", out.toString().indexOf("application/fastinfoset") > -1);
        assertTrue("response is expected fastinfoset", in.toString().indexOf("application/fastinfoset") > -1);
    } finally {
        bus.shutdown(true);
        pwOut.close();
        pwIn.close();
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Service(javax.xml.ws.Service) ClientConfigurer(org.jboss.ws.api.configuration.ClientConfigurer) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PrintWriter(java.io.PrintWriter)

Example 12 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class AddressingTestCase method testDecoupledEndpointForLongLastingProcessingOfInvocations.

/**
 * This shows the usage of decoupled-endpoint for getting back response on a new http connection.
 * The CXF client basically creates a destination listening at the provided decoupled endpoint address, using the
 * configured http transport factory. The client gets back a HTTP 202 accept response message immediately after
 * the call to the server, then once the actual response comes back to the decoupled endpoint, the client is
 * notified and returns control to the application code.
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testDecoupledEndpointForLongLastingProcessingOfInvocations() throws Exception {
    final Bus bus = BusFactory.newInstance().createBus();
    BusFactory.setThreadDefaultBus(bus);
    try {
        // construct proxy
        QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService");
        URL wsdlURL = new URL(baseURL + "/jaxws-samples-wsa/AddressingService?wsdl");
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
        Client client = ClientProxy.getClient(proxy);
        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        HTTPClientPolicy policy = conduit.getClient();
        // set low connection and receive timeouts to ensure the http client can't keep the connection open till the response is received
        // 5 secs
        policy.setConnectionTimeout(5000);
        // 10 secs
        policy.setReceiveTimeout(10000);
        try {
            // this takes at least 30 secs
            proxy.sayHello("Sleepy");
            fail("Timeout exception expected");
        } catch (WebServiceException e) {
            assertTrue(e.getCause() instanceof SocketTimeoutException);
        }
        policy.setDecoupledEndpoint("http://" + getServerHost() + ":18181/jaxws-samples-wsa/decoupled-endpoint");
        // this takes at least 30 secs... but now the client doesn't time out
        String response = proxy.sayHello("Sleepy");
        assertEquals("Hello Sleepy!", response);
    } finally {
        bus.shutdown(true);
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Bus(org.apache.cxf.Bus) SocketTimeoutException(java.net.SocketTimeoutException) WebServiceException(javax.xml.ws.WebServiceException) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Service(javax.xml.ws.Service) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Client(org.apache.cxf.endpoint.Client) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 13 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class PolicyInterceptorProviderTestCase method testUnsupportedPolicy.

/**
 * Verifies the policy-enabled client can be configured to ignore a given policy in the wsdl contract
 *
 * @throws Exception
 */
@Test
@RunAsClient
public void testUnsupportedPolicy() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        PolicyInterceptorProviderRegistry reg = bus.getExtension(PolicyInterceptorProviderRegistry.class);
        reg.register(new IgnorablePolicyInterceptorProvider(new QName("http://my.custom.org/policy", "MyPolicy")));
        URL wsdlURL = new URL(baseURL + "/jaxws-cxf-policy/PIPService/PIPEndpoint?wsdl");
        QName serviceName = new QName("http://policy.cxf.jaxws.ws.test.jboss.org/", "PIPService");
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        QName portQName = new QName("http://policy.cxf.jaxws.ws.test.jboss.org/", "PIPEndpointPort");
        PIPEndpoint port = (PIPEndpoint) service.getPort(portQName, PIPEndpoint.class);
        assertEquals("foo", port.echo("foo"));
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) PolicyInterceptorProviderRegistry(org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry) IgnorablePolicyInterceptorProvider(org.apache.cxf.ws.policy.IgnorablePolicyInterceptorProvider) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 14 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class PolicyInterceptorProviderTestCase method testUnsupportedPolicyFail.

@Test
@RunAsClient
public void testUnsupportedPolicyFail() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        URL wsdlURL = new URL(baseURL + "/jaxws-cxf-policy/PIPService/PIPEndpoint?wsdl");
        QName serviceName = new QName("http://policy.cxf.jaxws.ws.test.jboss.org/", "PIPService");
        Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
        QName portQName = new QName("http://policy.cxf.jaxws.ws.test.jboss.org/", "PIPEndpointPort");
        PIPEndpoint port = (PIPEndpoint) service.getPort(portQName, PIPEndpoint.class);
        try {
            port.echo("foo");
            fail("Exception expected");
        } catch (Exception e) {
            assertTrue(e.getMessage().contains("None of the policy alternatives can be satisfied"));
        }
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest)

Example 15 with UseThreadBusFeature

use of org.jboss.wsf.stack.cxf.client.UseThreadBusFeature in project jbossws-cxf by jbossws.

the class Helper method getPort.

private HelloWorld getPort(WebServiceFeature... features) throws MalformedURLException {
    URL wsdlURL = new URL(gzipFeatureEndpointURL + "?wsdl");
    QName serviceName = new QName("http://org.jboss.ws/jaxws/cxf/gzip", "HelloWorldService");
    Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
    QName portQName = new QName("http://org.jboss.ws/jaxws/cxf/gzip", "HelloWorldImplPort");
    return (HelloWorld) service.getPort(portQName, HelloWorld.class, features);
}
Also used : UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL)

Aggregations

UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)18 Service (javax.xml.ws.Service)17 URL (java.net.URL)16 QName (javax.xml.namespace.QName)16 Bus (org.apache.cxf.Bus)14 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)12 JBossWSTest (org.jboss.wsf.test.JBossWSTest)12 Test (org.junit.Test)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 PrintWriter (java.io.PrintWriter)6 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)6 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)3 WebServiceException (javax.xml.ws.WebServiceException)2 DigestAuthSupplier (org.apache.cxf.transport.http.auth.DigestAuthSupplier)2 WrapThreadContextClassLoader (org.jboss.wsf.test.WrapThreadContextClassLoader)2 OutputStream (java.io.OutputStream)1 MalformedURLException (java.net.MalformedURLException)1 SocketTimeoutException (java.net.SocketTimeoutException)1