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();
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations