第一步,首先写一个服务接口。
package demo.spring.service;
import javax.jws.WebService;
@WebService
public interface HelloWorld {
String sayHi(String text);
}
第二步,写一个实现类实现该接口
package demo.spring.service;
import javax.jws.WebService;
@WebService(endpointInterface = "demo.spring.service.HelloWorld")
public class HelloWorldImpl implements HelloWorld {
public String sayHi(String text) {
System.out.println("sayHi called");
return "Hello " + text;
}
}
第三步
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="hello" class="demo.spring.service.HelloWorldImpl" />
<jaxws:endpoint id="helloWorld" implementor="#hello"
address="/HelloWorld" />
</beans>

本文详细介绍了如何使用Spring框架创建服务接口、实现类,并通过XML配置文件将其部署为可访问的服务。从接口定义到实现类编写,再到配置文件的使用,涵盖了Spring框架下服务接口的完整开发流程。
2925

被折叠的 条评论
为什么被折叠?



