DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("http://admin:password@localhost:8080"+ "/services/MyService?wsdl"); Object[] a = client.invoke("test", ""); System.out.println(a);
/** * Create a new <code>Client</code> instance using the WSDL to be loaded * from the specified URL and using the current classloading context. * * @param wsdlURL the URL to load * @return */ public Client createClient(String wsdlUrl) { return createClient(wsdlUrl, (QName)null, (QName)null); } public Client createClient(String wsdlUrl, List<String> bindingFiles) {
/** * Create a new <code>Client</code> instance using the WSDL to be loaded * from the specified URL and with the specified <code>ClassLoader</code> * as parent. * * @param wsdlUrl * @param classLoader * @return */ public Client createClient(String wsdlUrl, ClassLoader classLoader) { return createClient(wsdlUrl, null, classLoader, null); } public Client createClient(String wsdlUrl, ClassLoader classLoader, List<String> bindingFiles) {
/** * Create a new <code>Client</code> instance using the WSDL to be loaded * from the specified URL and using the current classloading context. * * @param wsdlURL the URL to load * @return */ public Client createClient(String wsdlUrl) { return createClient(wsdlUrl, (QName)null, (QName)null); } public Client createClient(String wsdlUrl, List<String> bindingFiles) {
/** * Create a new <code>Client</code> instance using the WSDL to be loaded * from the specified URL and using the current classloading context. * * @param wsdlURL the URL to load * @return */ public Client createClient(URL wsdlUrl) { return createClient(wsdlUrl, (QName)null, (QName)null); } public Client createClient(URL wsdlUrl, List<String> bindingFiles) {
/** * Create a new <code>Client</code> instance using the WSDL to be loaded * from the specified URL and using the current classloading context. * * @param wsdlURL the URL to load * @return */ public Client createClient(URL wsdlUrl) { return createClient(wsdlUrl, (QName)null, (QName)null); } public Client createClient(URL wsdlUrl, List<String> bindingFiles) {
public Client createClient(URL wsdlUrl, List<String> bindingFiles) { return createClient(wsdlUrl, (QName)null, (QName)null, bindingFiles); }
public Client createClient(URL wsdlUrl, QName service, QName port) { return createClient(wsdlUrl, service, null, port); } public Client createClient(URL wsdlUrl, QName service, QName port, List<String> bindingFiles) {
public Client createClient(String wsdlUrl, QName service, QName port, List<String> bindingFiles) { return createClient(wsdlUrl, service, null, port, bindingFiles); }
public Client createClient(URL wsdlUrl, QName service, List<String> bindingFiles) { return createClient(wsdlUrl, service, null, bindingFiles); }
public Client createClient(URL wsdlUrl, QName service, ClassLoader classLoader, QName port, List<String> bindingFiles) { return createClient(wsdlUrl.toString(), service, classLoader, port, bindingFiles); }
public Client createClient(URL wsdlUrl, QName service, ClassLoader classLoader, QName port, List<String> bindingFiles) { return createClient(wsdlUrl.toString(), service, classLoader, port, bindingFiles); }
public Client createClient(URL wsdlUrl, QName service, QName port, List<String> bindingFiles) { return createClient(wsdlUrl.toString(), service, null, port, bindingFiles); }
String methodName = "getSomethingFromMyWebService"; DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient(ConsumeTest.class.getClassLoader().getResource("WebService.wsdl.xml")); Object[] res = client.invoke(methodName,parameter1,parameter2, parameterN); SomethingObject[] somethingObjectList = (SomethingObject[])res[0]; Class.forName(res.getClass().getName()).isArray(); for(SomethingObject so : somethingObjectList){ // do something! }
DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("WSDL Location"); AuthorizationPolicy authorization = ((HTTPConduit) client.getConduit()).getAuthorization(); authorization.setUserName( "user name" ); authorization.setPassword( "password" ); Object[] res = client.invoke(new QName("http://targetNameSpace/", "operationName"), params...); System.out.println("Echo response: " + res[0]);
protected Client createClient() throws Exception { synchronized (CLIENT_CREATION_LOCK) { DynamicClientFactory cf = DynamicClientFactory.newInstance(getBus()); return cf.createClient(getWsdlLocation(), (service == null ? null : QName.valueOf(service)), (getPort() == null ? null : QName.valueOf(getPort()))); } }
protected Client createClient() throws Exception { synchronized (CLIENT_CREATION_LOCK) { DynamicClientFactory cf = DynamicClientFactory.newInstance(getBus()); return cf.createClient(getWsdlLocation(), (service == null ? null : QName.valueOf(service)), (getPort() == null ? null : QName.valueOf(getPort()))); } }
@Test public void testBase64() 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(); DynamicClientFactory dynamicClientFactory = DynamicClientFactory.newInstance(bus); Client client = dynamicClientFactory.createClient(wsdlUrl); assertNotNull(client); }
@Test public void testCXF4676Partial1() throws Exception { DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("http://localhost:" + PORT + "/AddNumbersImplPartial1Service?wsdl", serviceName1, portName1); updateAddressPort(client, PORT); Object[] result = client.invoke("addTwoNumbers", 10, 20); assertNotNull("no response received from service", result); assertEquals(30, result[0]); }
@Test public void testCXF4676partial2() throws Exception { DynamicClientFactory dcf = DynamicClientFactory.newInstance(); Client client = dcf.createClient("http://localhost:" + PORT + "/AddNumbersImplPartial2Service?wsdl", serviceName2, portName2); updateAddressPort(client, PORT); Object[] result = client.invoke("addTwoNumbers", 10, 20); assertNotNull("no response received from service", result); assertEquals(30, result[0]); }