private Client getClient() throws BusException, EndpointException { if (client == null) { client = clientFactory.create(); if (null != authorizationPolicy) { HTTPConduit conduit = (HTTPConduit) client.getConduit(); conduit.setAuthorization(authorizationPolicy); } } return client; }
private Client createClient() throws BusException, EndpointException { Client client = clientFactory.create(); final Service service = client.getEndpoint().getService(); service.setDataBinding(new SourceDataBinding()); final ServiceInfo si = service.getServiceInfos().get(0); ServiceHelper.addOperation(si, operationName, isRequestResponse); return client; }
/** 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 ClientProxyFactoryBean factoryBean = createClientFactoryBean(cls); // configure client factory bean by CXF configurer configure(factoryBean); // 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())); } return ((ClientProxy) Proxy.getInvocationHandler(factoryBean.create())).getClient(); } else { ClientFactoryBean factoryBean = createClientFactoryBean(); // configure client factory bean by CXF configurer configure(factoryBean); // setup client factory bean setupClientFactoryBean(factoryBean); // 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 (Client) factoryBean.create(); } }