use of org.apache.cxf.frontend.ClientProxyFactoryBean in project camel by apache.
the class CxfConsumerTest method testInvokingServiceFromCXFClient.
// END SNIPPET: example
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.newInstance().createBus());
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo(TEST_MESSAGE);
assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);
Boolean bool = client.echoBoolean(Boolean.TRUE);
assertNotNull("The result should not be null", bool);
assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
}
use of org.apache.cxf.frontend.ClientProxyFactoryBean in project dubbo by alibaba.
the class WebServiceProtocol method doRefer.
@Override
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, URL url) throws RpcException {
ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
String servicePathPrefix = url.getParameter(SERVICE_PATH_PREFIX);
if (!StringUtils.isEmpty(servicePathPrefix) && PROTOCOL_SERVER_SERVLET.equals(url.getParameter(PROTOCOL_SERVER))) {
url = url.setPath(servicePathPrefix + "/" + url.getPath());
}
proxyFactoryBean.setAddress(url.setProtocol("http").toIdentityString());
proxyFactoryBean.setServiceClass(serviceType);
proxyFactoryBean.setBus(bus);
T ref = (T) proxyFactoryBean.create();
Client proxy = ClientProxy.getClient(ref);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(url.getParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
policy.setReceiveTimeout(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT));
conduit.setClient(policy);
return ref;
}
use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.
the class ExceptionTest method testHeaders.
@Test
public void testHeaders() throws Exception {
ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
proxyFac.setAddress("local://ExceptionService");
proxyFac.setBus(getBus());
setupAegis(proxyFac.getClientFactoryBean());
ExceptionService client = proxyFac.create(ExceptionService.class);
try {
client.sayHiWithException();
fail("Must throw exception!");
} catch (HelloException e) {
// nothing
}
// check to make sure the fault is an element
Document wsdl = getWSDLDocument("ExceptionService");
addNamespace("tns", "http://exception.aegis.cxf.apache.org");
assertValid("//wsdl:message[@name='HelloException']/wsdl:part[@name='HelloException']" + "[@element='tns:String']", wsdl);
}
use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.
the class ExceptionInheritanceTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
AegisContext globalContext = new AegisContext();
globalContext.setWriteXsiTypes(true);
Set<String> l = new HashSet<>();
l.add(SimpleBean.class.getName());
l.add(WS1ExtendedException.class.getName());
globalContext.setRootClassNames(l);
AegisDatabinding binding = new AegisDatabinding();
binding.setAegisContext(globalContext);
ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
setupAegis(pf.getClientFactoryBean(), binding);
pf.getServiceFactory().setProperties(props);
pf.setAddress("local://WS1");
pf.setProperties(props);
client = pf.create(WS1.class);
Server server = createService(WS1.class, new WS1Impl(), "WS1", binding);
server.getEndpoint().getService().setInvoker(new BeanInvoker(new WS1Impl()));
}
use of org.apache.cxf.frontend.ClientProxyFactoryBean in project cxf by apache.
the class DOMMappingTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
createService(DocumentService.class, "DocService");
ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean();
factory.getServiceConfigurations().add(0, new org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration());
proxyFac.setServiceFactory(factory);
proxyFac.setDataBinding(new AegisDatabinding());
proxyFac.setAddress("local://DocService");
proxyFac.setBus(getBus());
Object proxyObj = proxyFac.create(IDocumentService.class);
docClient = (IDocumentService) proxyObj;
Client client = ClientProxy.getClient(proxyObj);
ClientImpl clientImpl = (ClientImpl) client;
clientImpl.setSynchronousTimeout(1000000000);
}
Aggregations