天天看點

spring調用cxf webservice方法

spring對cxf的webservice調用做好很好的支援,隻需要一下步驟即可調用cxf:

1.加cxf的jar包:cxf-2.6.2.jar、neethi-3.0.2.jar、xmlschema-core-2.0.jar

2.增加spring配置檔案如下:

<bean id="subFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
  <property name="serviceClass"
   value="用eclipse生成的cxf用戶端接口類" />
  <property name="address"
   value="webservice的位址" />
</bean>
  
<bean id="subService" class="用eclipse生成的cxf用戶端接口類"
  factory-bean="subFactory" factory-method="create" />
           

上面需要用eclipse生成的cxf用戶端接口類即可。

如果其他的類要調用cxf的webservice接口,隻需要把subService注入即可。

繼續閱讀