@Override
public int plus(int a, int b) {
return a+b;
}
}
3============服务端
package com.clark.service;
import javax.xml.ws.Endpoint;
import com.clark.impl.HelloWorldImpl;
public class WebServiceApp {
public static void main(String[] args) {
System.out.println("web service start");
HelloWorldImpl implementor = new HelloWorldImpl();
String address = "http://localhost:8080/IHelloWorld";
Endpoint.publish(address, implementor);
System.out.println("web service started");
}
}
public class HelloWorldClient {
public static void main(String[] args) {
JaxWsProxyFactoryBean svr = new JaxWsProxyFactoryBean();
svr.setServiceClass(IHelloWorld.class);
svr.setAddress("http://localhost:8080/CXFWebService/service/IHelloWorld");
IHelloWorld hw = (IHelloWorld) svr.create();
String name = hw.sayHello(" CXF Apache implements Web Service");
int result = hw.plus(2, 3);
System.out.println(name);
System.out.println(result);
}
}
public class HelloWorldClient {
public static void main(String[] args) {
System.out.println("Web Service start..........");
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");