6. deserialize

基本信息

  1. 接口名称: com.webank.weid.suite.api.transportation.inf.PdfTransportation.deserialize
  2. 接口定义: <T extends JsonSerializer> ResponseData<T> deserialize(byte[] pdfTransportation, Class clazz, WeIdAuthentication weIdAuthentication);
  3. 接口描述: 用于反序列化对象,要求目标对象实现JsonSerializer接口。

接口入参:

名称类型非空说明备注
pdfTransportationbyte[ ]Y待反序列化的包含PDF信息的byte数组
clazzClass<T>Y目标类型
weIdAuthenticationWeIdAuthenticationYWeID公私钥信息

接口返回: <T extends JsonSerializer> com.webank.weid.protocol.response.ResponseData<T>;

名称类型说明备注
errorCodeInteger返回结果码
errorMessageString返回结果描述
result<T extends JsonSerializer>反序列化后的对象业务数据

此方法返回code

enumcodedesc
SUCCESS0成功
ENCRYPT_KEY_NOT_EXISTS100700无法获取秘钥
TRANSPORTATION_BASE_ERROR100800transportation基本未知异常
TRANSPORTATION_PROTOCOL_VERSION_ERROR100802协议版本错误
TRANSPORTATION_PROTOCOL_ENCODE_ERROR100803协议配置Encode异常
TRANSPORTATION_PROTOCOL_DATA_INVALID100805协议数据无效
TRANSPORTATION_ENCODE_BASE_ERROR100807Encode基本未知异常
PRESISTENCE_DATA_KEY_INVALID100901dataKey无效
UNKNOW_ERROR160003未知异常
BASE_ERROR160007weId基础未知异常
DATA_TYPE_CASE_ERROR160008数据转换异常
DIRECT_ROUTE_REQUEST_TIMEOUT160009AMOP超时
DIRECT_ROUTE_MSG_BASE_ERROR160010AMOP异常
SQL_EXECUTE_FAILED160011SQL执行异常
SQL_GET_CONNECTION_ERROR160013获取数据源连接异常

调用示例

  1. String weId = "did:weid:0x0106595955ce4713fd169bfa68e599eb99ca2e9f";
  2. List<String> verifierWeIdList = new ArrayList<String>();
  3. verifierWeIdList.add(weId);
  4.  
  5. PresentationE presentation;
  6. WeIdAuthentication weIdAuthentication = new WeIdAuthentication();
  7.  
  8. //序列化
  9. ResponseData<byte[]> result =
  10. TransportationFactory
  11. .newPdfTransportation()
  12. .specify(verifierWeIdList)
  13. .serialize(presentation,new ProtocolProperty(EncodeType.ORIGINAL),weIdAuthentication);
  14.  
  15. //序列化
  16. ResponseData<byte[]> result1 =
  17. TransportationFactory
  18. .newPdfTransportation()
  19. .specify(verifierWeIdList)
  20. .serialize(presentation,new ProtocolProperty(EncodeType.CIPHER),weIdAuthentication);
  21.  
  22. //原文方式调用反序列化
  23. ResponseData<PresentationE> resDeserialize =
  24. TransportationFactory
  25. .newPdfTransportation()
  26. .specify(verifierWeIdList)
  27. .deserialize(response.getResult(),PresentationE.class,weIdAuthentication);
  28.  
  29. //密文方式调用反序列化
  30. ResponseData<PresentationE> resDeserialize1 =
  31. TransportationFactory
  32. .newJsonTransportation()
  33. .specify(verifierWeIdList)
  34. .deserialize(response1.getResult(),PresentationE.class,weIdAuthentication);