本文整理汇总了Java中org.apache.cxf.frontend.ClientProxyFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java ClientProxyFactoryBean类的具体用法?Java ClientProxyFactoryBean怎么用?Java ClientProxyFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClientProxyFactoryBean类属于org.apache.cxf.frontend包,在下文中一共展示了ClientProxyFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSoapClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
public <T> T createSoapClient(Class<T> serviceClass, URL endpoint, String namespace)
{
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
factory.setBus(bus);
factory.setServiceClass(serviceClass);
factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
factory.setAddress(endpoint.toString());
factory.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatabilityConfiguration());
factory.setDataBinding(new AegisDatabinding());
@SuppressWarnings("unchecked")
T soapClient = (T) factory.create();
Client client = ClientProxy.getClient(soapClient);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setClient(policy);
return soapClient;
}
示例2: createSoap
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T> T createSoap(Class<T> serviceClass, URL endpoint, String namespace, Object previousSession)
{
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(serviceClass);
factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
factory.setAddress(endpoint.toString());
List<AbstractServiceConfiguration> configs = factory.getServiceFactory().getServiceConfigurations();
configs.add(0, new XFireReturnTypeConfig());
factory.setDataBinding(new AegisDatabinding());
T service = (T) factory.create();
Client client = ClientProxy.getClient(service);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setClient(policy);
if( previousSession != null )
{
copyCookiesInt(conduit, previousSession);
}
return service;
}
示例3: testInvokingServiceFromCXFClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(routerAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(bus);
HelloService client = (HelloService) proxyFactory.create();
try {
client.echo("hello world");
fail("Expect to get an exception here");
} catch (Exception e) {
assertEquals("Expect to get right exception message", EXCEPTION_MESSAGE, e.getMessage());
assertTrue("Exception is not instance of SoapFault", e instanceof SoapFault);
assertEquals("Expect to get right detail message", DETAIL_TEXT, ((SoapFault)e).getDetail().getTextContent());
//In CXF 2.1.2 , the fault code is per spec , the below fault-code is for SOAP 1.1
assertEquals("Expect to get right fault-code", "{http://schemas.xmlsoap.org/soap/envelope/}Client", ((SoapFault)e).getFaultCode().toString());
}
}
示例4: testInvokingServiceFromCXFClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
assertNotNull(client);
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");
int beforeCallingPing = pingCounter;
client.ping();
int afterCallingPing = pingCounter;
assertTrue("The ping operation doesn't be called", afterCallingPing - beforeCallingPing == 1);
}
示例5: execTest
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
private void execTest(int size) throws Exception {
buildTestMessage(size);
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
HelloService client = (HelloService) proxyFactory.create();
String result = client.echo(testMessage);
assertEquals("We should get the echo string result from router", "echo Hello World!", result);
//check received requests
assertEquals("Lengths of testMessage and receiveMessage should be equal (conversion body to String),", testMessage.length(), receivedMessageStringApplyingXPath.length());
assertEquals("Lengths of receivedMessageByDom and receivedMessageCxfPayloadApplyingXPath should be equal", receivedMessageCxfPayloadApplyingXPath.length(), receivedMessageByDom.length());
assertEquals("Lengths of testMessage and receiveMessage should be equal (body is CxfPayload),", testMessage.length(), receivedMessageCxfPayloadApplyingXPath.length());
}
示例6: testInvokingServiceFromCXFClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@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");
}
示例7: testInvokingServiceFromClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@Test
public void testInvokingServiceFromClient() throws Exception {
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(simpleEndpointAddress);
clientBean.setServiceClass(HelloService.class);
clientBean.setBus(BusFactory.getDefaultBus());
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");
}
示例8: initializeRemoteServiceRegistry
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
protected ServiceRegistry initializeRemoteServiceRegistry() {
String registryBootstrapUrl = ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.REGISTRY_SERVICE_URL);
if (StringUtils.isBlank(registryBootstrapUrl)) {
throw new RiceRuntimeException("Failed to load registry bootstrap service from url: " + registryBootstrapUrl);
}
ClientProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
clientFactory.setServiceClass(ServiceRegistry.class);
clientFactory.setBus(cxfBus);
clientFactory.setAddress(registryBootstrapUrl);
boolean registrySecurity = ConfigContext.getCurrentContextConfig().getBooleanProperty(SERVICE_REGISTRY_SECURITY_CONFIG, true);
// Set security interceptors
clientFactory.getOutInterceptors().add(new CXFWSS4JOutInterceptor(registrySecurity));
clientFactory.getInInterceptors().add(new CXFWSS4JInInterceptor(registrySecurity));
//Set transformation interceptors
clientFactory.getInInterceptors().add(new ImmutableCollectionsInInterceptor());
Object service = clientFactory.create();
if (!(service instanceof ServiceRegistry)) {
throw new RiceRuntimeException("Endpoint to service registry at URL '" + registryBootstrapUrl + "' was not an instance of ServiceRegistry, instead was: " + service);
}
return (ServiceRegistry)service;
}
示例9: configureClientProxyFactoryBean
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
/**
* Configure the client proxy factory; currently set the binding customization in the databinding (Client Side).
*
* @param factory
*/
protected void configureClientProxyFactoryBean(ClientProxyFactoryBean factory)
{
//Configure binding customization
if (customization != null)
{
//customize default databinding (early pulls in ServiceFactory default databinding and configure it, as it's lazily loaded)
ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
serviceFactory.reset();
DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
configureBindingCustomization(serviceFactoryDataBinding, customization);
serviceFactory.setDataBinding(serviceFactoryDataBinding);
//customize user provided databinding (CXF later overrides the ServiceFactory databinding using the user provided one)
if (factory.getDataBinding() == null)
{
//set the endpoint factory's databinding to prevent CXF resetting everything because user did not provide anything
factory.setDataBinding(serviceFactoryDataBinding);
}
else
{
configureBindingCustomization(factory.getDataBinding(), customization);
}
}
//add other configurations here below
}
示例10: testCallAxis2
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@Test
@Ignore
public void testCallAxis2(){
//服务位于: http://localhost/axis2-web/services/myService?wsdl
// JaxWsClientFactoryBean clientBean=new JaxWsClientFactoryBean();
// JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
ClientProxyFactoryBean factoryBean=new ClientProxyFactoryBean();
factoryBean.setAddress("http://localhost/axis2-web/services/myService?wsdl");
factoryBean.setServiceClass(MyService.class); //有接口调用
//修复兼容性:
//发现居然提示命名空间不对,原来是CXF认为命名空间用/结尾,多一个斜杠引起问题
factoryBean.setServiceName(new QName("http://sevice.test.axis2","MyService"));
factoryBean.getInInterceptors().add(new LoggingInInterceptor());
factoryBean.getOutInterceptors().add(new LoggingOutInterceptor());
MyService service=(MyService)factoryBean.create();
System.out.println(service.getHello("将"));//当前类
String result=service.toBaseString("Hello, jiyi", 100);//父类方法
System.out.println(result);
}
示例11: doRefer
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
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(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
conduit.setClient(policy);
return ref;
}
示例12: getNewClient
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
protected SoapHarvesterService getNewClient(String url, String sharedId, String sharedValue, String username)
{
try
{
final URL endpointUrl = new URL(new URL(url), HARVESTER_ENDPOINT);
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
factory.setBus(bus);
factory.setServiceClass(SoapHarvesterService.class);
factory.setServiceName(
new QName("http://soap.harvester.core.tle.com", SoapHarvesterService.class.getSimpleName()));
factory.setAddress(endpointUrl.toString());
factory.setDataBinding(new AegisDatabinding());
List<AbstractServiceConfiguration> configs = factory.getServiceFactory().getServiceConfigurations();
configs.add(0, new XFireReturnTypeConfig());
SoapHarvesterService soapClient = (SoapHarvesterService) factory.create();
Client client = ClientProxy.getClient(soapClient);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
// Works?
// conduit.getTlsClientParameters().setSSLSocketFactory(BlindSSLSocketFactory.getDefaultSSL());
conduit.setClient(policy);
soapClient.loginWithToken(TokenGenerator.createSecureToken(username, sharedId, sharedValue, null));
return soapClient;
}
catch( Exception x )
{
LOGGER.error("Error connecting to remote EQUELLA server", x);
throw new RuntimeException(
CurrentLocale.get("com.tle.core.remoterepo.equella.error.communication", x.getMessage()));
}
}
示例13: getWsClientProxy
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
public static Object getWsClientProxy(
Class<?> clientClass,
String wsUrl,
String wsUserName,
String wsPassword,
String authType,
boolean generateTimestamp,
boolean logCalls,
boolean disableCnCheck,
Integer timeout) {
ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(wsUrl);
factory.setServiceClass(clientClass);
if (logCalls) {
factory.getInInterceptors().add(new LoggingInInterceptor());
factory.getOutInterceptors().add(new LoggingOutInterceptor());
}
String authTypeBo = authType;
if (authTypeBo == null || authTypeBo.length() == 0) {
if (wsUserName != null && wsUserName.length() > 0)
authTypeBo = "BASIC";
}
if ("BASIC".equalsIgnoreCase(authTypeBo)) {
factory.setUsername(wsUserName);
factory.setPassword(wsPassword);
} else if ("USERNAMETOKEN".equalsIgnoreCase(authTypeBo)) {
Map<String, Object> wss4jInterceptorProps = new HashMap<String, Object>();
if (generateTimestamp) {
wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN);
} else {
wss4jInterceptorProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
}
wss4jInterceptorProps.put(WSHandlerConstants.USER, wsUserName);
wss4jInterceptorProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
ClientPasswordCallback cp = new ClientPasswordCallback(wsPassword);
wss4jInterceptorProps.put(WSHandlerConstants.PW_CALLBACK_REF, cp);
factory.getOutInterceptors().add(new WSS4JOutInterceptor(wss4jInterceptorProps));
}
Object c = factory.create();
Client client = ClientProxy.getClient(c);
HTTPConduit httpConduit = (HTTPConduit)client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
if (timeout != null) {
httpClientPolicy.setConnectionTimeout(timeout);
httpClientPolicy.setReceiveTimeout(timeout);
}
// Envio chunked
httpClientPolicy.setAllowChunking(isWsClientChunked());
httpConduit.setClient(httpClientPolicy);
if (disableCnCheck) {
TLSClientParameters tlsParams = new TLSClientParameters();
tlsParams.setDisableCNCheck(true);
httpConduit.setTlsClientParameters(tlsParams);
}
return c;
}
示例14: doRefer
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws JahhanException {
ClientProxyFactoryBean proxyFactoryBean = new ClientProxyFactoryBean();
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(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT));
conduit.setClient(policy);
return ref;
}
示例15: getProxy
import org.apache.cxf.frontend.ClientProxyFactoryBean; //导入依赖的package包/类
public static LoanBrokerWS getProxy(String address) {
// Now we use the simple front API to create the client proxy
ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
clientBean.setAddress(address);
clientBean.setServiceClass(LoanBrokerWS.class);
// just create a new bus for use
clientBean.setBus(BusFactory.newInstance().createBus());
return (LoanBrokerWS) proxyFactory.create();
}