eclipse+webservice开发实例

参考文献:


           1.利用Java编写简单的WebService实例  

2.Axis2与Eclipse整合开发Web Service  

3.bservice helloword例子

4.创建WebService实例

5.使用Eclipse+Axis2+Tomcat构建Web Services应用(实例讲解篇)

6.使用eclipse建立webservice服务和客户端

7.eclipse+webservice开发实例

8.【Java】WebService 整理实例(代码实战带图文)


--------------------- 

配置:

一、 必须jar包:【pom.xml】(这个找了好久

        <!-- 这里直接导入整个项目下的所有jar包,其中去除几个 -->
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>apache-cxf</artifactId>
			<version>3.2.6</version>
			<type>pom</type>
			<exclusions>
				<exclusion>
					<artifactId>cxf-services-wsn-api</artifactId>
					<groupId>org.apache.cxf.services.wsn</groupId>
				</exclusion>
				<exclusion>
					<artifactId>cxf-services-wsn-core</artifactId>
					<groupId>org.apache.cxf.services.wsn</groupId>
				</exclusion>
				<exclusion>
					<artifactId>cxf-services-ws-discovery-api</artifactId>
					<groupId>org.apache.cxf.services.ws-discovery</groupId>
				</exclusion>
				<exclusion>
					<artifactId>cxf-services-ws-discovery-service</artifactId>
					<groupId>org.apache.cxf.services.ws-discovery</groupId>
				</exclusion>
			</exclusions>
		</dependency>

二、web.xml

<servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/webService/*</url-pattern>
</servlet-mapping>

三、spring-DataSource.xml

1.头配置

xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap"

http://cxf.apache.org/jaxws 
http://cxf.apache.org/schemas/jaxws.xsd

2.引入【pom引入jar包自带】

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

3.配置调用接口

<!-- 配置方式2 注意:implementor为接口的具体实现类 -->
<jaxws:endpoint implementor="com.XXX.base.service.InfoServiceImpl"
		address="/InfoServiceImpl"></jaxws:endpoint>

四、具体实现

具体底层就不讲了,主要讲一下webservice接口配置

1.接口方法上注解

eclipse+webservice开发实例

2.方法上注解

eclipse+webservice开发实例

3. 实现类注解

eclipse+webservice开发实例

五、具体实现:【doc命令】

【需要生成到某项目主目录】wsimport -s D:\workspace\项目名\src
【需要生成到某项目包名】-p com.cn.test  
【webservice服务端】 -keep http://IP:9091/接口项目名/webService/接口实现类名?wsdl  

例如:

wsimport -s D:\workspace\SSM-webserver\src\main\java

-p com.test

-keep http://localhost:9091/webserver/webService/webService?wsdl

在doc命令的时候直接放成一行就可以,以上我是为了大家看的比较清晰,写成分行的

开发完成:

访问网页:http://localhost:9091/webserver/webService/webService?wsdl

出现以下页面表示开发成功

eclipse+webservice开发实例

六、提供一个源码,我的现用项目版本是从整个版本整合出来的

链接:https://pan.baidu.com/s/16LdMqP2dhQTQAY2rzYY2PA    提取码:pg5t