81,122
社区成员




public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(HelloWorld.class);
factory.setAddress("http://localhost:8080/WebService");
HelloWorld helloWorld = (HelloWorld) factory.create();
System.out.println("==========");
System.out.println(helloWorld.sayHello("webservice"));
}
package test;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
public String sayHello(String content);
}
package test;
import javax.jws.WebService;
@WebService
public class HelloWorldImpl implements HelloWorld {
public String sayHello(String content) {
System.out.println("qw---------sayhello");
return "server:"+content;
}
}
public static void main(String args[]) throws Exception {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(HelloWorldImpl.class);
factory.setAddress("http://localhost:8080/WebService");
Server server = factory.create();
server.start();
}
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
public class WeatherClient {
public static void main(String[] args) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Weather.class);
factory.setAddress("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
Weather weather = (Weather) factory.create();
System.out.println("==========");
String[] arrayCity = weather.getSupportCity("all");
for (int i = 0; i < arrayCity.length; i++) {
System.out.println(arrayCity[i]);
}
}
}