xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
com.itzheng
cxfServer
0.0.1-SNAPSHOT
war
org.apache.cxf
cxf-rt-frontend-jaxws
3.1.10
org.apache.cxf
cxf-rt-transports-http
3.1.10
org.springframework
spring-beans
4.2.4.RELEASE
org.springframework
spring-web
4.2.4.RELEASE
org.apache.maven.plugins
maven-compiler-plugin
2.3.2
1.71.7
org.apache.tomcat.maven
tomcat7-maven-plugin
9090
IWeatherService
package com.itzheng.cxfserver;
import javax.jws.WebService;
/*
*/
@WebService
public interface IWeatherService {
//根据城市返回天气信息
String info(String city);
}
WeatherService
public class WeatherService implements IWeatherService {
@Override
public String info(String city) {
if(“北京”.equals(city)) {
return “雾霾”;
}
return “晴天”;
}
}
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath*:applicationContext*.xml
cxf
org.apache.cxf.transport.servlet.CXFServlet
cxf
/ws/*
<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.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id=“weatherService”
class=“com.itzheng.cxfserver.impl.WeatherService”>
<jaxws:server address=“/weatherService”>
jaxws:serviceBean
</jaxws:serviceBean>
</jaxws:server>
http://localhost:9090/cxf/ws/weatherService?wsdl
http://localhost:9090/cxf/ws/weatherService?wsdl=IWeatherService.wsdl
运行显示结果
解析上述返回信息:从下往上看
查看项目文件路径
返回工程当中并刷新工程
自动生成一些类和方法
<project xmlns=“http://maven.apache.org/POM/4.0.0”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
com.itzheng
cxfServer
0.0.1-SNAPSHOT
war
org.apache.cxf
cxf-rt-frontend-jaxws
3.1.10
org.apache.cxf
cxf-rt-transports-http
3.1.10
org.springframework
spring-context
4.2.4.RELEASE
junit
junit
4.11
本人也收藏了一份Java面试核心知识点来应付面试,借着这次机会可以送给我的读者朋友们:
Java面试核心知识点
一共有30个专题,足够读者朋友们应付面试啦,也节省朋友们去到处搜刮资料自己整理的时间!
Java面试核心知识点
groupId>
spring-context
4.2.4.RELEASE
junit
junit
4.11
本人也收藏了一份Java面试核心知识点来应付面试,借着这次机会可以送给我的读者朋友们:
[外链图片转存中…(img-pYWSjMOj-1725077478072)]
Java面试核心知识点
一共有30个专题,足够读者朋友们应付面试啦,也节省朋友们去到处搜刮资料自己整理的时间!
[外链图片转存中…(img-FZ3SPpNK-1725077478072)]
Java面试核心知识点
因篇幅问题不能全部显示,请点此查看更多更全内容