Java Code Examples for org.apache.cxf.frontend.ClientProxyFactoryBean#setAddress()
The following examples show how to use
org.apache.cxf.frontend.ClientProxyFactoryBean#setAddress() .
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: 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 2
Source File: DocLitBareTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testNamespaceCrash() { ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setServiceClass(University.class); svrFactory.setTransportId(LocalTransportFactory.TRANSPORT_ID); svrFactory.setAddress("local://dlbTest"); svrFactory.setServiceBean(new UniversityImpl()); svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding()); svrFactory.create(); ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.getServiceFactory().setDataBinding(new AegisDatabinding()); factory.setServiceClass(University.class); factory.setTransportId(LocalTransportFactory.TRANSPORT_ID); factory.setAddress("local://dlbTest"); University client = (University) factory.create(); Teacher tr = client.getTeacher(new Course(40, "Intro to CS", "Introductory Comp Sci")); assertNotNull(tr); assertEquals(52, tr.getAge()); assertEquals("Mr. Tom", tr.getName()); }
Example 3
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 4
Source File: Client.java From cxf with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); if (args != null && args.length > 0 && !"".equals(args[0])) { factory.setAddress(args[0]); } else { factory.setAddress("http://localhost:9000/Hello"); } factory.getServiceFactory().setDataBinding(new AegisDatabinding()); HelloWorld client = factory.create(HelloWorld.class); System.out.println("Invoke sayHi()...."); System.out.println(client.sayHi(System.getProperty("user.name"))); Document doc = client.getADocument(); Element e = (Element) doc.getFirstChild(); System.out.println(e.getTagName()); Text t = (Text) e.getFirstChild(); System.out.println(t); }
Example 5
Source File: ExceptionInheritanceTest.java From cxf with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { super.setUp(); AegisContext globalContext = new AegisContext(); globalContext.setWriteXsiTypes(true); Set<String> l = new HashSet<>(); l.add(SimpleBean.class.getName()); l.add(WS1ExtendedException.class.getName()); globalContext.setRootClassNames(l); AegisDatabinding binding = new AegisDatabinding(); binding.setAegisContext(globalContext); ClientProxyFactoryBean pf = new ClientProxyFactoryBean(); setupAegis(pf.getClientFactoryBean(), binding); pf.getServiceFactory().setProperties(props); pf.setAddress("local://WS1"); pf.setProperties(props); client = pf.create(WS1.class); Server server = createService(WS1.class, new WS1Impl(), "WS1", binding); server.getEndpoint().getService().setInvoker(new BeanInvoker(new WS1Impl())); }
Example 6
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 7
Source File: ClientServerMiscTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testSimpleClientWithWsdlAndBindingId() 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.setBindingId("http://cxf.apache.org/bindings/xformat"); factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL_XMLBINDING + "?wsdl"); factory.setServiceName(servName); factory.setServiceClass(DocLitWrappedCodeFirstService.class); factory.setEndpointName(portName); factory.setAddress(ServerMisc.DOCLIT_CODEFIRST_URL_XMLBINDING); DocLitWrappedCodeFirstService port = (DocLitWrappedCodeFirstService) factory.create(); assertNotNull(port); assertEquals(factory.getBindingId(), "http://cxf.apache.org/bindings/xformat"); assertTrue(ClientProxy.getClient(port).getEndpoint().getBinding() instanceof XMLBinding); String echoMsg = port.echo("Hello"); assertEquals("Hello", echoMsg); }
Example 8
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 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: 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 11
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 12
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 13
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 14
Source File: AegisClientServerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testAegisClient() throws Exception { AegisDatabinding aegisBinding = new AegisDatabinding(); ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean(); proxyFactory.setDataBinding(aegisBinding); proxyFactory.setServiceClass(AuthService.class); proxyFactory.setAddress("http://localhost:" + PORT + "/service"); AuthService service = (AuthService) proxyFactory.create(); assertTrue(service.authenticate("Joe", "Joe", "123")); assertFalse(service.authenticate("Joe1", "Joe", "fang")); assertTrue(service.authenticate("Joe", null, "123")); List<String> list = service.getRoles("Joe"); assertEquals(3, list.size()); assertEquals("Joe", list.get(0)); assertEquals("Joe-1", list.get(1)); assertEquals("Joe-2", list.get(2)); String[] roles = service.getRolesAsArray("Joe"); assertEquals(2, roles.length); assertEquals("Joe", roles[0]); assertEquals("Joe-1", roles[1]); assertEquals("get Joe", service.getAuthentication("Joe")); Authenticate au = new Authenticate(); au.setSid("ffang"); au.setUid("ffang"); assertTrue(service.authenticate(au)); au.setUid("ffang1"); assertFalse(service.authenticate(au)); }
Example 15
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 16
Source File: Client.java From cxf with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); if (args != null && args.length > 0 && !"".equals(args[0])) { factory.setAddress(args[0]); } else { factory.setAddress("http://localhost:9000/Hello"); } HelloWorld client = factory.create(HelloWorld.class); System.out.println("Invoke sayHi()...."); System.out.println(client.sayHi(System.getProperty("user.name"))); System.exit(0); }
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 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-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 20
Source File: CxfClientToJaxwsServerIT.java From tracee with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Before public void setup() { JaxWsServerFactoryBean jaxWsServer = createJaxWsServer(); jaxWsServer.getHandlers().add(new TraceeClientHandler(serverBackend)); 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.setAddress(endpointAddress); helloWorldPort = (HelloWorldTestService) factoryBean.create(); }