3. getWeIdDocumentJson

基本信息

  1. 接口名称:com.webank.weid.rpc.WeIdService.getWeIdDocumentJson
  2. 接口定义:ResponseData<String> getWeIdDocumentJson(String weId)
  3. 接口描述: 根据WeIdentity DID查询WeIdentity DID Document信息,并以JSON格式返回。

接口入参: String

名称类型非空说明备注
weIdStringYWeIdentity DID字符串

接口返回: com.webank.weid.protocol.response.ResponseData<String>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
resultStringweidDocument Json

此方法返回code

enumcodedesc
SUCCESS0成功
WEID_INVALID100101无效的WeIdentity DID
WEID_DOES_NOT_EXIST100104WeIdentity DID不存在
TRANSACTION_TIMEOUT160001超时
TRANSACTION_EXECUTE_ERROR160002交易错误
UNKNOW_ERROR160003其他错误

调用示例

  1. WeIdService weIdService = new WeIdServiceImpl();
  2. ResponseData<String> response = weIdService.getWeIdDocumentJson("did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a");
  1. 返回结果如下:
  2. result: {"@context" : "https://github.com/WeBankFinTech/WeIdentity/blob/master/context/v1",
  3. "id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
  4. "created" : 1560419409898,
  5. "updated" : 1560419409898,
  6. "publicKey" : [ {
  7. "id" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0",
  8. "type" : "Secp256k1",
  9. "owner" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a",
  10. "publicKey" : "2905679808560626772263712571437125497429146398815877180317365034921958007199576809718056336050058032599743534507469742764670961100255274766148096681073592"
  11. } ],
  12. "authentication" : [ {
  13. "type" : "Secp256k1",
  14. "publicKey" : "did:weid:101:0xd9aeaa982fc21ea9addaf09e4f0c6a23a08d306a#keys-0"
  15. } ],
  16. "service" : [ {
  17. "type" : "drivingCardService",
  18. "serviceEndpoint" : "https://weidentity.webank.com/endpoint/xxxxx"
  19. } ]
  20. }
  21. errorCode: 0
  22. errorMessage: success
  23. 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