ClassLoader loader = this.getClass().getClassLoader(); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("wsdlPath", classLoader);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("http://ws.strikeiron.com/IPLookup2?wsdl"); Thread.currentThread().setContextClassLoader(classLoader);
ClassLoader loader = this.getClass().getClassLoader(); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("wsdlPath", classLoader);
/** * 创建动态客户端对象 * * @param wsdlUrl web service地址 * * @return {@link Client} */ public static Client createDynamicClient(String wsdlUrl) { if (clientMap.containsKey(wsdlUrl)) { return clientMap.get(wsdlUrl); } Client client = jaxWsDynamicClientFactory.createClient(wsdlUrl); clientMap.put(wsdlUrl, client); return client; }
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("ws.strikeiron.com/IPLookup2?WSDL"); Thread.currentThread().setContextClassLoader(classLoader);
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("echo.wsdl"); Object[] res = client.invoke("echo", "test echo"); System.out.println("Echo response: " + res[0]);
/** * Creates and returns service * * @param wsdlLocation wsdl location url * @return */ protected Client getDynamicClient(String wsdlLocation) { if (wsdlLocation == null) { throw new IllegalArgumentException("wsdlLocation can't be null"); } JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); Client client = clientFactory.createClient(wsdlLocation); return client; } }
Client client = dcf.createClient(wsdlUrl, CXFWebServiceCommand.class.getClassLoader()); ExecutionResults results = new ExecutionResults(); try {
@Test public void testCxf5061() throws Exception { if (JavaUtils.isJava9Compatible()) { System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true"); } //using dcf to generate client from the wsdl which ensure the wsdl is valid JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); dcf.createClient(ADDRESS + "?wsdl"); }
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(bus); Client client = dcf.createClient(wsdl);
@Test public void testJaxWsDynamicClient() throws Exception { URL wsdl = getClass().getResource("/wsdl/others/dynamic_client_base64.wsdl"); assertNotNull(wsdl); String wsdlUrl = null; wsdlUrl = wsdl.toURI().toString(); CXFBusFactory busFactory = new CXFBusFactory(); Bus bus = busFactory.createBus(); org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory dynamicClientFactory = org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory.newInstance(bus); Client client = dynamicClientFactory.createClient(wsdlUrl); assertNotNull(client); }
@Test public void testArrayList() throws Exception { JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl")); String[] values = new String[] {"foobar", "something" }; List<String> list = Arrays.asList(values); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getInInterceptors().add(new LoggingInInterceptor()); client.invoke("init", list); }
@Test public void testArgfiles() throws Exception { System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true"); JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient(new URL("http://localhost:" + PORT1 + "/ArrayService?wsdl")); String[] values = new String[] {"foobar", "something" }; List<String> list = Arrays.asList(values); client.getOutInterceptors().add(new LoggingOutInterceptor()); client.getInInterceptors().add(new LoggingInInterceptor()); client.invoke("init", list); }
@Test public void testDynamicClientExceptions() throws Exception { if (JavaUtils.isJava9Compatible()) { System.setProperty("org.apache.cxf.common.util.Compiler-fork", "true"); } JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); URL wsdlURL = new URL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl"); Client client = dcf.createClient(wsdlURL); try { client.invoke("throwException", -2); } catch (Exception ex) { Object o = ex.getClass().getMethod("getFaultInfo").invoke(ex); assertNotNull(o); } try { client.getRequestContext().put("disable-fault-mapping", true); client.invoke("throwException", -2); } catch (SoapFault ex) { //expected } }
@org.junit.Test public void testGetWSDL() throws Exception { BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); bus.getInInterceptors().add(new LoggingInInterceptor()); bus.getOutInterceptors().add(new LoggingOutInterceptor()); MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); factory.createClient(ADDRESS + "?wsdl"); }
@org.junit.Test public void testGetWSDL() throws Exception { BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); bus.getInInterceptors().add(new LoggingInInterceptor()); bus.getOutInterceptors().add(new LoggingOutInterceptor()); MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); factory.createClient(ADDRESS + "?wsdl"); }
@org.junit.Test public void testGetWSDL() throws Exception { BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); bus.getInInterceptors().add(new LoggingInInterceptor()); bus.getOutInterceptors().add(new LoggingOutInterceptor()); MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); factory.createClient(ADDRESS + "?wsdl"); }
@Test public void testGetWSDL() throws Exception { BusFactory bf = BusFactory.newInstance(); Bus bus = bf.createBus(); bus.getInInterceptors().add(new LoggingInInterceptor()); bus.getOutInterceptors().add(new LoggingOutInterceptor()); MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer(); bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class); JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus); factory.createClient(ADDRESS + "?wsdl"); }
public final void testSuccessfulCall(String configuration, String address, URL url, boolean dynamicClient) throws Exception { setTheConfiguration(configuration); startServers(); if (url == null) { url = SOAPService.WSDL_LOCATION; } //CXF-4037 - dynamic client isn't using the conduit settings to resolve schemas if (dynamicClient) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); JaxWsDynamicClientFactory.newInstance(BusFactory.getDefaultBus()) .createClient(url.toExternalForm()); Thread.currentThread().setContextClassLoader(loader); } SOAPService service = new SOAPService(url, SOAPService.SERVICE); assertNotNull("Service is null", service); final Greeter port = service.getHttpsPort(); assertNotNull("Port is null", port); BindingProvider provider = (BindingProvider)port; provider.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address); //for (int x = 0; x < 100000; x++) { assertEquals(port.greetMe("Kitty"), "Hello Kitty"); //} stopServers(); }
@Test public void testInvocation() throws Exception { JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); URL wsdlURL = new URL("http://localhost:" + PORT + "/NoBodyParts/NoBodyPartsService?wsdl"); Client client = dcf.createClient(wsdlURL); byte[] bucketOfBytes = IOUtils.readBytesFromStream(getClass().getResourceAsStream("/wsdl/no_body_parts.wsdl")); Operation1 parameters = new Operation1(); parameters.setOptionString("opt-ion"); parameters.setTargetType("tar-get"); Object[] rparts = client.invoke("operation1", parameters, bucketOfBytes); Operation1Response r = (Operation1Response)rparts[0]; assertEquals(md5(bucketOfBytes), r.getStatus()); ClientCallback callback = new ClientCallback(); client.invoke(callback, "operation1", parameters, bucketOfBytes); rparts = callback.get(); r = (Operation1Response)rparts[0]; assertEquals(md5(bucketOfBytes), r.getStatus()); }