我已经开始用Spring学习Apache CXF了.首先,我尝试创建一个简单的客户端/服务器模型.
服务器端是: service.HelloWorld.java
@WebService
public interface HelloWorld {
  String sayHi(String text);
}
Run Code Online (Sandbox Code Playgroud)
service.HelloWorldImpl.java
@WebService(endpointInterface = "service.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
   public String sayHi(String text) {
     return "Hello, " + text;
   }
}
Run Code Online (Sandbox Code Playgroud)
客户端是: client.Client.java public class Client {
    public static void main(String[] args) {
          ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new  String[] {"cxf-client-servlet.xml"});
          HelloWorld client = (HelloWorld) context.getBean("client");
          System.out.println(client.sayHi("Batman"));
    }
}
Run Code Online (Sandbox Code Playgroud)
CXF的客户端 - servlet.xml中
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:jaxws="http://cxf.apache.org/jaxws"
 xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    http://cxf.apache.org/jaxws
    http://cxf.apache.org/schema/jaxws.xsd">
<bean id="client" class="service.HelloWorld" factory-bean="clientFactory" factory-method="create"/>
<bean …Run Code Online (Sandbox Code Playgroud)