集成spring与Web容器教程
- J2EE
- 关注:1.12W次
spring框架的主要优势之一就是其分层架构,分层架构允许使用者选择使用哪一个组件,同时为 J2EE 应用程序开发提供集成的框架。下面yjbys小编为大家准备了关于集成spring与Web容器教程,欢迎阅读。
1.创建HelloWorld 接口类
package oworld;
import ethod;
import aram;
import esult;
import ervice;
@WebService
public interface HelloWorld {
@WebMethod
@WebResult String sayHi(@WebParam String text);
}
2.创建HelloWorld实现类
package oworld;
public class HelloWorldImpl implements HelloWorld {
public String sayHi(String name) {
String msg = "Hello " + name + "!";
return msg;
}
}
3.修改文件
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"_2_" >
cxfstudy
cxf
ervlet
1
cxf
/ws/*
extLoaderListener
contextConfigLocation
classpath*:**/
4.创建spring配置文件并放在classpath路径下
xmlns:xsi="" xmlns:jaxws=""
xsi:schemaLocation="
">
5.创建测试类
package oworld;
import icationContext;
import sPathXmlApplicationContext;
public class SpringClient {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("");
HelloWorld helloworld = (HelloWorld)ean("helloworldClient");
tln(i("kongxx"));
}
}
6.测试
6.1 首先启动tomcat或者使用maven的jetty,并访问http://localhost:9000/ws/HelloWorld?wsdl来验证web service已经启动并且生效;
6.2 然后运行测试类来验证web service。
- 文章版权属于文章作者所有,转载请注明 https://xuezhezhai.com/itrz/j2ee/0l359n.html