@Override @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; }
@Override @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; }
Object obj = super.create(); Service service = getServiceFactory().getService(); if (needWrapperClassInterceptor(service.getServiceInfos().get(0))) {
public Object create() { configured = true; return super.create(); } public synchronized Object getObject() throws Exception {
public Object create() { configured = true; return super.create(); } public synchronized Object getObject() throws Exception {
/** * Create a proxy object that implements a specified Service Endpoint Interface. This * method is a combination of {@link #setServiceClass(Class)} and {@link #create()}. * @param <ProxyServiceType> The type for the SEI. * @param serviceClass The Java class object representing the interface you want. * @return the proxy. */ public <ProxyServiceType> ProxyServiceType create(Class<ProxyServiceType> serviceClass) { setServiceClass(serviceClass); return serviceClass.cast(create()); } private void configureObject() {
/** * Create a proxy object that implements a specified Service Endpoint Interface. This * method is a combination of {@link #setServiceClass(Class)} and {@link #create()}. * @param <ProxyServiceType> The type for the SEI. * @param serviceClass The Java class object representing the interface you want. * @return the proxy. */ public <ProxyServiceType> ProxyServiceType create(Class<ProxyServiceType> serviceClass) { setServiceClass(serviceClass); return serviceClass.cast(create()); } private void configureObject() {
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); // Configure factory MyService serviceClient = (MyService) factory.create(MyService.class); MyService proxy = (MyService) Proxy.newProxyInstance( ServiceInvocationHandler.class.getClassLoader(), new Class[] { MyService.class }, new ServiceInvocationHandler(serviceClient));
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass( MyPort.class ); factory.setAddress( "http://www.host.com/service" ); factory.setServiceName( new QName( targetNamespace, wsdlBindingName ) ); Object myService = factory.create(); org.apache.cxf.endpoint.Client client = ClientProxy.getClient( myService ); Map<String, List<String>> headers = new HashMap<String, List<String>>(); headers.put("SOAPAction", Arrays.asList("mySoapAction")); client.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); client.invoke( operationName, request );
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(HelloWorld.class); factory.setAddress("http://localhost:9000/Hello"); HelloWorld client = (HelloWorld) factory.create();
public Object create() { if (getClientProxyFactoryBean() == null) { throw new IllegalStateException("clientProxyFactoryBean can't be null"); } final Object client = getClientProxyFactoryBean().create(); prepare(client); return client; } }
/* Connect to the service */ ClientProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean(); factoryBean.setServiceClass(MyService.class); factoryBean.setAddress("service-url"); myService = (MyService) factoryBean.create(); /* Retrive HTTP client policy and set the receive timeout */ Client client = ClientProxy.getClient(myService); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = httpConduit.getClient(); httpClientPolicy.setReceiveTimeout(timeoutMilliseconds);
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(); }
ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(AWSECommerceServicePortType.class); factory.setAddress("https://soap.amazon.com/onca/soap?Service=AWSECommerceService"); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.getOutInterceptors().add(new LoggingOutInterceptor()); AWSECommerceServicePortType ss = (AWSECommerceServicePortType) factory.create();
private void setupForTest(boolean enableClientMTOM) throws Exception { AegisDatabinding aegisBinding = new AegisDatabinding(); aegisBinding.setMtomEnabled(enableClientMTOM); ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setDataBinding(aegisBinding); proxyFac.setAddress("http://localhost:" + PORT + "/mtom"); JaxWsProxyFactoryBean jaxwsFac = new JaxWsProxyFactoryBean(); jaxwsFac.setDataBinding(new AegisDatabinding()); jaxwsFac.setAddress("http://localhost:" + PORT + "/jaxWsMtom"); Map<String, Object> props = new HashMap<>(); if (enableClientMTOM) { props.put("mtom-enabled", Boolean.TRUE); } proxyFac.setProperties(props); client = proxyFac.create(MtomTestService.class); jaxwsClient = jaxwsFac.create(MtomTestService.class); impl = (MtomTestImpl)applicationContext.getBean("mtomImpl"); }
@Test public void testSimpleClientWithWsdl() throws Exception { QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstServicePort"); QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", "DocLitWrappedCodeFirstService"); ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"); factory.setServiceName(servName); factory.setServiceClass(DocLitWrappedCodeFirstService.class); factory.setEndpointName(portName); DocLitWrappedCodeFirstService port = (DocLitWrappedCodeFirstService) factory.create(); assertNotNull(port); String echoMsg = port.echo("Hello"); assertEquals("Hello", echoMsg); }
@Override @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; }
@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; }
@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; }
@Override @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; }