use of org.apache.cxf.frontend.ClientFactoryBean 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.ClientFactoryBean in project camel by apache.
the class CxfSpringEndpoint method createClient.
// Package private methods
// -------------------------------------------------------------------------
/**
* Create a CXF Client
*/
@Override
Client createClient() throws Exception {
// get service class
Class<?> cls = getSEIClass();
if (getDataFormat().equals(DataFormat.POJO)) {
ObjectHelper.notNull(cls, CxfConstants.SERVICE_CLASS);
}
if (getWsdlURL() == null && cls == null) {
// no WSDL and serviceClass specified, set our default serviceClass
setServiceClass(org.apache.camel.component.cxf.DefaultSEI.class.getName());
setDefaultOperationNamespace(CxfConstants.DISPATCH_NAMESPACE);
setDefaultOperationName(CxfConstants.DISPATCH_DEFAULT_OPERATION_NAMESPACE);
if (getDataFormat().equals(DataFormat.PAYLOAD)) {
setSkipPayloadMessagePartCheck(true);
}
cls = getSEIClass();
}
if (cls != null) {
// create client factory bean
ClientFactoryBean factoryBean = createClientFactoryBean(cls);
// setup client factory bean
setupClientFactoryBean(factoryBean, cls);
// fill in values that have not been filled.
QName serviceQName = null;
try {
serviceQName = factoryBean.getServiceName();
} catch (IllegalStateException e) {
// It throws IllegalStateException if serviceName has not been set.
}
if (serviceQName == null && getServiceLocalName() != null) {
factoryBean.setServiceName(new QName(getServiceNamespace(), getServiceLocalName()));
}
if (factoryBean.getEndpointName() == null && getEndpointLocalName() != null) {
factoryBean.setEndpointName(new QName(getEndpointNamespace(), getEndpointLocalName()));
}
Client client = factoryBean.create();
// setup the handlers
setupHandlers(factoryBean, client);
return client;
} else {
ClientFactoryBean factoryBean = createClientFactoryBean();
// setup client factory bean
setupClientFactoryBean(factoryBean, null);
// fill in values that have not been filled.
QName serviceQName = null;
try {
serviceQName = factoryBean.getServiceName();
} catch (IllegalStateException e) {
// It throws IllegalStateException if serviceName has not been set.
}
if (serviceQName == null && getServiceLocalName() != null) {
factoryBean.setServiceName(new QName(getServiceNamespace(), getServiceLocalName()));
}
if (factoryBean.getEndpointName() == null && getEndpointLocalName() != null) {
factoryBean.setEndpointName(new QName(getEndpointNamespace(), getEndpointLocalName()));
}
checkName(factoryBean.getEndpointName(), "endpoint/port name");
checkName(factoryBean.getServiceName(), "service name");
return factoryBean.create();
}
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfHolderConsumerTest method testInvokingServiceWithSoapHeaderFromCXFClient.
@Test
public void testInvokingServiceWithSoapHeaderFromCXFClient() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(ADDRESS);
clientBean.setServiceClass(MyOrderEndpoint.class);
MyOrderEndpoint client = (MyOrderEndpoint) proxyFactory.create();
Holder<String> header = new Holder<String>();
header.value = "parts";
String result = client.mySecureOrder(1, header);
assertEquals("Get a wrong order result", "Ordered ammount 1", result);
assertEquals("Get a wrong parts", "secureParts", header.value);
}
use of org.apache.cxf.frontend.ClientFactoryBean in project camel by apache.
the class CxfHolderConsumerTest method testInvokingServiceFromCXFClient.
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(ADDRESS);
clientBean.setServiceClass(MyOrderEndpoint.class);
MyOrderEndpoint client = (MyOrderEndpoint) proxyFactory.create();
Holder<String> strPart = new Holder<String>();
strPart.value = "parts";
Holder<String> strCustomer = new Holder<String>();
strCustomer.value = "";
String result = client.myOrder(strPart, 2, strCustomer);
assertEquals("Get a wrong order result", "Ordered ammount 2", result);
assertEquals("Get a wrong parts", "parts", strPart.value);
assertEquals("Get a wrong customer", "newCustomer", strCustomer.value);
}
Aggregations