3. getWeIdDocumentJson
基本信息
- 接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocumentJson
- 接口定义:ResponseData<String> getWeIdDocumentJson(String weId)
- 接口描述: 根据WeIdentity DID查询WeIdentity DID Document信息,并以JSON格式返回。
接口入参: String
名称 | 类型 | 非空 | 说明 | 备注 |
---|---|---|---|---|
weId | String | Y | WeIdentity DID字符串 |
接口返回: com.webank.weid.protocol.response.ResponseData<String>;
名称 | 类型 | 说明 | 备注 |
---|---|---|---|
errorCode | Integer | 返回结果码 | |
errorMessage | String | 返回结果描述 | |
result | String | weidDocument Json |
此方法返回code
enum | code | desc |
---|---|---|
SUCCESS | 0 | 成功 |
WEID_INVALID | 100101 | 无效的WeIdentity DID |
WEID_DOES_NOT_EXIST | 100104 | WeIdentity DID不存在 |
TRANSACTION_TIMEOUT | 160001 | 超时 |
TRANSACTION_EXECUTE_ERROR | 160002 | 交易错误 |
UNKNOW_ERROR | 160003 | 其他错误 |
调用示例
- WeIdService weIdService = new WeIdServiceImpl();
- ResponseData<String> response = weIdService.getWeIdDocumentJson("did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a");
- 返回结果如下:
- result: {"@context" : "https://github.com/WeBankFinTech/WeIdentity/blob/master/context/v1",
- "id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
- "created" : 1560419409898,
- "updated" : 1560419409898,
- "publicKey" : [ {
- "id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0",
- "type" : "Secp256k1",
- "owner" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
- "publicKey" : "2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592"
- } ],
- "authentication" : [ {
- "type" : "Secp256k1",
- "publicKey" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0"
- } ],
- "service" : [ {
- "type" : "drivingCardService",
- "serviceEndpoint" : "https://weidentity.webank.com/endpoint/xxxxx"
- } ]
- }
- errorCode: 0
- errorMessage: success
- transactionInfo:null
时序图
(同时也包含getWeIDDocment时序)
sequenceDiagram调用者->>WeIdentity SDK : 传入指定的WeIdentity DIDWeIdentity SDK->>区块链节点: 调用智能合约区块链节点->>区块链节点: 查找记录该WeIdentity DID关联的属性事件最后一次更新时的块高区块链节点—>>WeIdentity SDK: 返回loop 解析事件WeIdentity SDK->>区块链节点: 根据块高,过滤该区块里的属性事件区块链节点—>>WeIdentity SDK: 返回WeIdentity SDK->>WeIdentity SDK: 根据块高,获取到对应区块所有交易WeIdentity SDK->>WeIdentity SDK: 根据交易获取交易回执WeIdentity SDK->>WeIdentity SDK: 根据交易回执过滤跟当前WeIdentity DID相关的属性事件WeIdentity SDK->>WeIdentity SDK: 根据不同的key,解析public key, authentication, service endpointWeIdentity SDK->>WeIdentity SDK: 组装WeIdentity DocumentWeIdentity SDK->>WeIdentity SDK: 根据当前事件找到上一个事件对应的块高endWeIdentity SDK—>>调用者:返回WeIdentity Document