- import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
- public class Client {
- public static void main(String[] args) {
- JaxWsProxyFactoryBean bean = new JaxWsProxyFactoryBean();
- bean.setServiceClass(HelloWorldService.class);
- bean.setAddress("http://localhost:9090/helloWorldService");
- HelloWorldService helloWorldService = (HelloWorldService)bean.create();
- String result = helloWorldService.sayHello("Kevin");
- System.out.println(result);
- }
-
- import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
- public class Client2 {
- public static void main(String[] args) throws Exception {
- JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
- Client client = clientFactory.createClient("http://localhost:9090/helloWorldService?wsdl");
- Object[] result = client.invoke("sayHello", "KEVIN");
- System.out.println(result[0]);
- }
- }
3、JaxWsServerFactoryBean