Java Code Examples for org.apache.cxf.frontend.ClientProxyFactoryBean#setBus()
The following examples show how to use
org.apache.cxf.frontend.ClientProxyFactoryBean#setBus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebServiceProtocol.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: StudentTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testMapMap() throws Exception { ServerFactoryBean sf = new ServerFactoryBean(); sf.setServiceClass(StudentServiceDocLiteral.class); sf.setServiceBean(new StudentServiceDocLiteralImpl()); sf.setAddress("local://StudentServiceDocLiteral"); setupAegis(sf); Server server = sf.create(); server.start(); ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setAddress("local://StudentServiceDocLiteral"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); //CHECKSTYLE:OFF HashMap<String, Student> mss = new HashMap<>(); mss.put("Alice", new Student()); HashMap<String, HashMap<String, Student>> mmss = new HashMap<>(); mmss.put("Bob", mss); StudentServiceDocLiteral clientInterface = proxyFac.create(StudentServiceDocLiteral.class); clientInterface.takeMapMap(mmss); //CHECKSTYLE:ON }
Example 3
Source File: LazyRemoteServiceRegistryConnector.java From rice with Educational Community License v2.0 | 6 votes |
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; }
Example 4
Source File: DOMMappingTest.java From cxf with Apache License 2.0 | 6 votes |
@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); }
Example 5
Source File: FlatArrayTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testFlatCollection() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client = proxyFac.create(FlatArrayServiceInterface.class); BeanWithFlatCollection bwfc = new BeanWithFlatCollection(); bwfc.getValues().add(1); bwfc.getValues().add(2); bwfc.getValues().add(3); bwfc = client.echoBeanWithFlatCollection(bwfc); assertEquals(3, bwfc.getValues().size()); assertEquals(Integer.valueOf(1), bwfc.getValues().get(0)); assertEquals(Integer.valueOf(2), bwfc.getValues().get(1)); assertEquals(Integer.valueOf(3), bwfc.getValues().get(2)); }
Example 6
Source File: ProxyTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testProxy() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setAddress("local://HelloProxyService"); proxyFac.setBus(getBus()); AegisContext aegisContext = new AegisContext(); aegisContext.getBeanImplementationMap().put(Hello.class, MyHello.class.getName()); AegisDatabinding binding = new AegisDatabinding(); binding.setAegisContext(aegisContext); setupAegis(proxyFac.getClientFactoryBean(), binding); HelloProxyService client = proxyFac.create(HelloProxyService.class); Hello h = client.sayHiWithProxy(); assertTrue(h instanceof MyHello); }
Example 7
Source File: ExceptionTest.java From cxf with Apache License 2.0 | 6 votes |
@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); }
Example 8
Source File: ExceptionTest.java From cxf with Apache License 2.0 | 6 votes |
@Test(expected = HelloException.class) public void testJaxwsServerSimpleClient() throws Exception { JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean(); sfbean.setServiceClass(ExceptionService.class); sfbean.setDataBinding(new AegisDatabinding()); sfbean.setAddress("local://ExceptionServiceJaxWs1"); Server server = sfbean.create(); Service service = server.getEndpoint().getService(); service.setInvoker(new BeanInvoker(new ExceptionServiceImpl())); ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setAddress("local://ExceptionServiceJaxWs1"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); ExceptionService clientInterface = proxyFac.create(ExceptionService.class); clientInterface.sayHiWithException(); }
Example 9
Source File: CxfClientToCxfServerIT.java From tracee with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() { JaxWsServerFactoryBean jaxWsServer = createJaxWsServer(); jaxWsServer.getFeatures().add(new LoggingFeature()); jaxWsServer.getFeatures().add(new TraceeCxfFeature(serverBackend, Profile.DEFAULT)); server = jaxWsServer.create(); final ClientProxyFactoryBean factoryBean = new ClientProxyFactoryBean(); factoryBean.getFeatures().add(new LoggingFeature()); factoryBean.getFeatures().add(new TraceeCxfFeature(clientBackend, Profile.DEFAULT)); factoryBean.setServiceClass(HelloWorldTestService.class); factoryBean.setBus(CXFBusFactory.getDefaultBus()); factoryBean.setAddress(endpointAddress); helloWorldPort = (HelloWorldTestService) factoryBean.create(); }
Example 10
Source File: MissingTypeWSDLTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testMissingTransliteration() throws Exception { Server server = createService(MissingType.class, new MissingTypeImpl(), null); Service service = server.getEndpoint().getService(); service.setInvoker(new BeanInvoker(new MissingTypeImpl())); ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setAddress("local://MissingType"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); Document wsdl = getWSDLDocument("MissingType"); assertValid("/wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='urn:org:apache:cxf:aegis:type:missing']" + "/xsd:complexType[@name=\"Inner\"]", wsdl); }
Example 11
Source File: CollectionTestsWithService.java From cxf with Apache License 2.0 | 5 votes |
@Before public void before() { impl = new CollectionService(); createService(CollectionServiceInterface.class, impl, null); ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatibilityServiceConfiguration()); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://CollectionServiceInterface"); proxyFac.setBus(getBus()); csi = proxyFac.create(CollectionServiceInterface.class); }
Example 12
Source File: FlatArrayTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testDataMovementBean() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client = proxyFac.create(FlatArrayServiceInterface.class); BeanWithFlatArray bwfa = new BeanWithFlatArray(); bwfa.setValues(INT_ARRAY); client.takeBeanWithFlatArray(bwfa); assertArrayEquals(INT_ARRAY, service.beanWithFlatArrayValue.getValues()); }
Example 13
Source File: FlatArrayTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testDataMovementPart() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://FlatArray"); proxyFac.setBus(getBus()); FlatArrayServiceInterface client = proxyFac.create(FlatArrayServiceInterface.class); client.submitStringArray(STRING_ARRAY); assertArrayEquals(STRING_ARRAY, service.stringArrayValue); }
Example 14
Source File: ClientServiceConfigTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void ordinaryParamNameTest() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean(); proxyFac.setServiceFactory(factory); proxyFac.setDataBinding(new AegisDatabinding()); proxyFac.setAddress("local://Echo"); proxyFac.setBus(getBus()); Echo echo = proxyFac.create(Echo.class); String boing = echo.simpleEcho("reflection"); assertEquals("reflection", boing); }
Example 15
Source File: InterfaceInheritanceTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testClient() throws Exception { ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean(); proxyFac.setAddress("local://IInterfaceService"); proxyFac.setBus(getBus()); setupAegis(proxyFac.getClientFactoryBean()); IInterfaceService client = proxyFac.create(IInterfaceService.class); IChild child = client.getChild(); assertNotNull(child); assertEquals("child", child.getChildName()); assertEquals("parent", child.getParentName()); IParent parent = client.getChildViaParent(); assertEquals("parent", parent.getParentName()); assertFalse(parent instanceof IChild); IGrandChild grandChild = client.getGrandChild(); assertEquals("parent", grandChild.getParentName()); Document wsdl = getWSDLDocument("IInterfaceService"); assertValid("//xsd:complexType[@name='IGrandChild']", wsdl); assertValid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='grandChildName']", wsdl); assertValid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][1]", wsdl); assertInvalid("//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][2]", wsdl); assertValid("//xsd:complexType[@name='IChild']", wsdl); assertValid("//xsd:complexType[@name='IParent']", wsdl); assertInvalid("//xsd:complexType[@name='IChild'][@abstract='true']", wsdl); }
Example 16
Source File: WebServiceProtocol.java From dubbox with Apache License 2.0 | 5 votes |
@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; }
Example 17
Source File: WebServiceProtocol.java From dubbox with Apache License 2.0 | 5 votes |
@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; }
Example 18
Source File: WebServiceProtocol.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
@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; }
Example 19
Source File: WebServiceProtocol.java From dubbox with Apache License 2.0 | 5 votes |
@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; }