CXF呼叫傳遞物件引數
阿新 • • 發佈:2019-02-09
簡單傳遞文字呼叫:
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client client = dcf.createClient("echo.wsdl");
Object[] res = client.invoke("echo", "test echo");
System.out.println("Echo response: " + res[0]);
傳遞物件,呼叫
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); Client client = dcf.createClient("people.wsdl"); Object person = Thread.currentThread().getContextClassLoader().loadClass("com.acme.Person").newInstance(); Method m = person.getClass().getMethod("setName", String.class); m.invoke(person, "Joe Schmoe"); Method m1 = person.getClass().getMethod("setCustomerID", String.class); Method m2 = person.getClass().getMethod("setItemID", String.class); Method m3 = person.getClass().getMethod("setQty", Integer.class); Method m4 = person.getClass().getMethod("setPrice", Double.class); m1.invoke(person, "C001"); m2.invoke(person, "I001"); m3.invoke(person, 100); m4.invoke(person, 200.00); client.invoke("addPerson", person);