本文先发布在:封宸落宇 再同步发布到本博客!
CXF结合spring发布简单的webservice服务!

基于CXF 发布webservice服务
1、创建web工程 ,添加spring(3.1.3)包,添加cxf(2.2.6)依赖包
2、创建配置文件:applicationContext-webservice.xml
文件内容:
1
2
3
4
5
6
7
8
9
10
@H_ 404_49@
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
<?
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
:
context
=
"http://www.springframework.org/schema/context"
xmlns
:
jaxws
=
"http://cxf.apache.org/jaxws"
xsi
:
schemaLocation
=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
"
>
<
import
resource
=
"classpath:meta-inf/cxf/cxf.xml"
/
>
<
!
--
定义实现类
implementor参数写的是
spring
bean的 名称,和发布地址
--
>
<
jaxws
:
endpoint
id
=
"SyncAddressBookService"
implementor
=
"#SyncAddressBookService"
address
=
"/SyncAddressBookService"
publish
=
"true"
>
<
jaxws
:
features
>
<
bean
class
=
"org.apache.cxf.feature.LoggingFeature"
/
>
<
/
jaxws
:
features
>
<
/
jaxws
:
endpoint
>
<
bean
id
=
"com.zte.ucm.sync_in_soap.sync_ipop_service.impl.SyncAddressBookServiceImpl"
/
>
<
/
beans
>
|
然后在applicationContext.xml中将applicationContext-webservice.xml添加进来。
|
<
import
resource
=
"applicationContext-webservice.xml"
/
>
|
3、在web.xml中,添加cxf servlet定义!
上面定义的cxfservlet对于URL中带有UserPrdBindService的请求都将过滤,对于上面的定义访问:http://ip/UserPrdBindService/SyncAddressBookService?wsdl就能够访问到发布的服务。
4、创建服务接口
/
5、创建接口实现类
|
@WebService
(
targetNamespace
endpointInterface
"com.zte.ucm.sync_in_soap.sync_ipop_service.SyncAddressBookService"
)
class
SyncAddressBookServiceImpl
implements
{
private
static
final
Logger
log
Logger
.
getLogger
(
SyncAddressBookServiceImpl
.
class
)
;
xml
)
{
return
"0"
;
}
}
|
6、部署并启动,访问:http://ip/UserPrdBindService/SyncAddressBookService?wsdl 能够获取到wsdl文件,恭喜你已经成功利用cxf结合spring发布了一个webservice服务了!
服务发布了,那怎么访问呢,请查看我的另一篇博客!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。