用CXF来调用webService

CXF发布服务,有三种形式:根据main方法发布【Java Project项目】;不基于spring方式发布到Web容器中,比如Tomcat容器【web项目】;基于Spring方式发布到Web容器中。【web项目】

1. Java的webService实现本身就是一个很耗性能的实现方案(xml与java对象之间在服务端以及客户端的互转比较消耗性能)

2. 目前java主流的webService应用以CXF、AXIS2为主;

3. 通过网络渠道的了解,目前CXF的效率要比AXIS2高出至少50%;

4. CXF在java应用实现中已经很成熟,企业更倾向于用这样一个成熟的解决方案;

5. CXF和Spring高度集成。

1.通过CXF调用service的条件

 

<dependency>
   <groupId>
org.apache.cxf</groupId>
   <artifactId>
cxf-rt-frontend-jaxws</artifactId>
   <version>
${cxf.version}</version>
</dependency>
<dependency>
   <groupId>
org.apache.cxf</groupId>
   <artifactId>
cxf-rt-transports-http</artifactId>
   <version>
${cxf.version}</version>
</dependency>
<dependency>
   <groupId>
org.apache.cxf</groupId>
   <artifactId>
cxf-rt-transports-http-jetty</artifactId>
   <version>
${cxf.version}</version>
</dependency>

 

2.通过CXF调用service的方法

 

Object[] invoke(String operationName,

              Object... params)

                throws Exception

Invokes an operation synchronously

Parameters:

operationName - The name of the operation to beinvoked. The service namespace will be used when looking up theBindingOperationInfo.

params - The params that matches theparts of the input message of the operation. If the BindingOperationInfosupports unwrapping, it assumes the params are in the "unwrapped"form. If params are in the wrapped form, use invokeWrapped

Returns:

The return values that matche the parts of the outputmessage of the operation

Throws:

Exception

北京耳软骨垫鼻尖 http://www.ahwndz.com/BJYestar/show-10-3171-1.shtml

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值