# chinaport-data-signature

Version | Update Time | Status | Author | Description
--- | --- | --- | --- | ---
1.0 | 2022-02-16 10:30 | 创建 | Weasley J | 创建api文档

## 1. 电子口岸报文加签Controller

### 1.1. 海关数据加签

URL: http://localhost:8080/rpc/eport/signature

Type: POST

Author: lwj

Content-Type: application/json; charset=utf-8

Description: 此接口已经整合"海关总署XML"和"海关179数据抓取"的加签

Body-parameters:

Parameter | Type | Required | Description
--- | --- | --- | ---
id | int32 | false | 唯一id, 用来区分是哪一次发送的消息，默认值=1，从1开始，{@code int} 最大, 231-1.

data

string

true

加签源数据

支持的加签数据类型
- 1. 不带ds:Signature节点的CEBXxxMessage.xml原文;待加签xml报文样例
- 2. 海关179加签数据; 数据格式请传符合「海关179数据规范」的标准字符串,入参示例:

      "sessionID":"ad2254-8hewyf32-55616249"||"payExchangeInfoHead":"{"guid":"9D55BA71-22DE-41F4-8B50-C36C83B3B530","initalRequest":"原始请求","initalResponse":"ok","ebpCode":"4404840022","payCode":"312226T001","payTransactionId":"2018121222001354081010726129","totalAmount":100,"currency":"142","verDept":"3","payType":"1","tradingTime":"20181212041803","note":"批量订单，测试订单优化,生成多个so订单"}"||"payExchangeInfoLists":"[{"orderNo":"SO1710301150602574003","goodsInfo":[{"gname":"lhy-gnsku3","itemLink":"http://m.yunjiweidian.com/yunjibuyer/static/vue-buyer/idc/index.html#/detail?itemId=999761&shopId=453"},{"gname":"lhy-gnsku2","itemLink":"http://m.yunjiweidian.com/yunjibuyer/static/vue-buyer/idc/index.html#/detail?itemId=999760&shopId=453"}],"recpAccount":"OSA571908863132601","recpCode":"","recpName":"YUNJIHONGKONGLIMITED"}]"||"serviceTime":"1544519952469"

Request-body:

    {
      "id": 853,
      "data": "8d1vh0"
    }

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
message | string | 返回消息 | -
success | boolean | 是否成功 | -
timestamp | string | 响应时间戳 | -
code | int32 | 状态码 | -
data | object | 响应数据 | -
└─success | boolean | 本次加签是否成功 | -
└─certNo | string | 签名的ukey的卡序列号 | -

└─x509Certificate

string

签名的ukey证书

如需导出.cer证书,文件格式:卡序列号.cer
- 证书导出帮助连接

-

└─digestValue

string

xml的数字摘要，先对不包含Signature节点的原始报文,进行C14n格式化，然后取shal二进制摘要，然后对sha1的值进行base64编码

- 待加签报文样例

-

└─signatureValue | string | 调用ukey获取的签名值 | -

Response-example:

    {
      "message": "success",
      "success": true,
      "timestamp": "2022-02-19 16:57:28",
      "code": 109,
      "data": {
        "success": true,
        "certNo": "9tbp27",
        "x509Certificate": "jbfw0r",
        "digestValue": "e2ayjq",
        "signatureValue": "nfl2g7"
      }
    }

Curl-example:

    curl -X POST -H 'Content-Type: application/json; charset=utf-8' -i http://localhost:8080/rpc/eport/signature --data '{
      "id": 853,
      "data": "8d1vh0"
    }'

### 1.2. 海关总署XML数据加签测试

URL: http://localhost:8080/rpc/eport/signature/test/ceb

Type: GET

Author: lwj

Content-Type: application/x-www-form-urlencoded;charset=utf-8

Description: 非正式调用API，只为了让你看到海关总署XML加密的数据返回格式

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
message | string | 返回消息 | -
success | boolean | 是否成功 | -
timestamp | string | 响应时间戳 | -
code | int32 | 状态码 | -
data | object | 响应数据 | -
└─any object | object | any object. | -

Response-example:

    {
      "message": "success",
      "success": true,
      "timestamp": "2022-02-19 16:57:28",
      "code": 689,
      "data": {}
    }

Curl-example:

    curl -X GET -i http://localhost:8080/rpc/eport/signature/test/ceb

### 1.3. 海关179数据抓取加签测试

URL: http://localhost:8080/rpc/eport/signature/test/179

Type: GET

Author: lwj

Content-Type: application/x-www-form-urlencoded;charset=utf-8

Description: 非正式调用API，只为了让你看到179加密的数据返回格式

Response-fields:

Field | Type | Description | Since
--- | --- | --- | ---
message | string | 返回消息 | -
success | boolean | 是否成功 | -
timestamp | string | 响应时间戳 | -
code | int32 | 状态码 | -
data | object | 响应数据 | -
└─any object | object | any object. | -

Response-example:

    {
      "message": "success",
      "success": true,
      "timestamp": "2022-02-19 16:57:28",
      "code": 899,
      "data": {}
    }

Curl-example:

    curl -X GET -i http://localhost:8080/rpc/eport/signature/test/179

Top