Spring+CXF实现联通vac和sp对接

一、联通vac请求报文
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="http://req.sync.soap.bossagent.vac.unicom.com" xmlns:m1="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body>
    <m:orderRelationUpdateNotify xmlns:m="http://soap.bossagent.vac.unicom.com" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <orderRelationUpdateNotifyRequest xsi:type="m0:OrderRelationUpdateNotifyRequest">
        <recordSequenceId>201806251813057005</recordSequenceId>
        <userIdType>1</userIdType>
        <userId>18627818645</userId>
        <serviceType>90</serviceType>
        <spId>44494</spId>
        <productId>9071992401</productId>
        <updateType>1</updateType>
        <updateTime>20180625180931</updateTime>
        <updateDesc>106553574</updateDesc>
        <linkId/>
        <content>Y</content>
        <effectiveDate>20180625181000</effectiveDate>
        <expireDate>21001231000000</expireDate>
        <time_stamp>0625181305</time_stamp>
        <encodeStr>1862781864590719924010625181305</encodeStr>
      </orderRelationUpdateNotifyRequest>
    </m:orderRelationUpdateNotify>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
二、maven依赖
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring-version>4.3.7.RELEASE</spring-version>
    <cxf.version>3.1.8</cxf.version>
</properties>

<dependencies>
    <!-- spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${spring-version}</version>
    </dependency>

    <!-- cxf依赖 -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-core</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-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
</dependencies>
三、配置web.xml
<context-param>
    <param-name>contextConfigLocation</param-name>
    <!-- 加载配置文件 -->
    <param-value>classpath:spring-cxf.xml</param-value>
</context-param>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- CXF配置 -->
<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>/*</url-pattern>
</servlet-mapping>
四、配置spring-cxf.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    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://cxf.apache.org/jaxws 
        http://cxf.apache.org/schemas/jaxws.xsd"
    default-autowire="byType" default-lazy-init="true">

    <description>Apache CXF的WebService配置</description>

    <!-- 发布服务 -->
    <jaxws:endpoint id="orderRelationUpdateNotify"
        implementor="com.unicom.vac.bossagent.soap.OrderRelationUpdateNotifyImpl"
        address="/orderRelationUpdateNotifyService" />
</beans>
五、创建对应的包和java文件
5.1 创建包com.unicom.vac.bossagent.soap
5.2 创建OrderRelationUpdateNotifyRequest
/**
 * sp请求参数 . <br>
 * 
 * @author hkb <br>
 */
public class OrderRelationUpdateNotifyRequest {

    /** 流水号 */
    private String recordSequenceId;

    /** 用户ID类型 */
    private Integer userIdType;

    /** 用户手机号码或伪码 */
    private String userId;

    /** 业务类型 */
    private String serviceType;

    /** SP标识 */
    private String spId;

    /** 产品标识 */
    private String productId;

    /** 更新操作的类型 */
    private Integer updateType;

    /** 更新时间 */
    private String updateTime;

    /** 更新操作的详细描述 */
    private String updateDesc;

    /** 事务关联ID */
    private String linkId;

    /** 内容 */
    private String content;

    /** 订购关系生效时间 */
    private String effectiveDate;

    /** 订购关系失效时间 */
    private String expireDate;

    /** 时间戳由VAC生成 */
    private String time_stamp;

    /** */
    private String encodeStr;

    // 省略getter/setter
}
5.3 创建Response
/**
 * sp返回结果 . <br>
 * 
 * @author hkb <br>
 */
public class Response {

    /** 流水号 */
    private String recordSequenceId;

    /** 结果标识: 0-正确,1-错误 */
    private int resultCode;

    // 省略getter/setter
}
5.4 创建OrderRelationUpdateNotifyService
/**
 * sp接口 . <br>
 * 
 * @author hkb <br>
 */
@WebService(targetNamespace = "http://soap.bossagent.vac.unicom.com")
public interface OrderRelationUpdateNotifyService {

    @WebMethod(operationName = "orderRelationUpdateNotify")
    public Response orderRelationUpdateNotify(
            @WebParam(name = "orderRelationUpdateNotifyRequest") OrderRelationUpdateNotifyRequest orderRelationUpdateNotifyRequest);

}
5.5 创建OrderRelationUpdateNotifyImpl
/**
 * sp实现类 . <br>
 * 
 * @author hkb <br>
 */
@WebService
public class OrderRelationUpdateNotifyImpl implements OrderRelationUpdateNotifyService {

    @Override
    public Response orderRelationUpdateNotify(OrderRelationUpdateNotifyRequest orderRelationUpdateNotifyRequest) {
        Response response = new Response();
        response.setRecordSequenceId(orderRelationUpdateNotifyRequest.getRecordSequenceId());
        response.setResultCode(0);
        return response;
    }

}
六、运行项目和测试
6.1 测试地址:http://localhost:8080/sp/orderRelationUpdateNotifyService?wsdl
6.2 测试结果

这里写图片描述

6.3 完整代码:https://download.csdn.net/download/hkhhkb/10501047
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值