在maven项目中 配置代理对象远程调用crm

时间:2023-03-09 18:38:02
在maven项目中 配置代理对象远程调用crm

1 在maven项目中配置代理对象远程调用crm

1.1 在项目的pom.xml中引入CXF的依赖

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.0.1</version>
</dependency>

1.2 使用wsimport命令解析wsdl文件生成本地代码,只需要接口文件和实体类

命令为:wsimport -s . -p com.javaweb.crm http://ip:port/service/service?wsdl

其中-p表示命名一个文件包名

在maven项目中 配置代理对象远程调用crm

1.3 在spring配置文件中注册crm客户端代理对象

需要导入约束:

<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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<!-- 注册crm客户端代理对象 -->
<jaxws:client id="crmClient" serviceClass="com.javaweb.crm.ICustomerService" address="http://ip:prot/crm_javaweb/service/service" />

1.4 通过注解方式将代理对象注入action

在maven项目中 配置代理对象远程调用crm