知识卡片

结构图卡 · 5025.e

入站消息分三层检查

理解等级:中级

收到服务响应后依次检查协议、结构和值。协议检查状态码、媒体类型和必要头;结构检查本次工作需要的字段、链接及表单是否存在;值检查类型、范围以及控制的必要属性。只在验证满足业务前提后才计算并提交结果。

使用JSON/XML路径查询可精确提取需要的节点,不必因无关新增字段拒绝整个响应。严格schema不涵盖全部协议检查,也可能产生可处理消息被误拒的问题;容忍扩展不等于忽略必需字段或错误值。

关联:[[发送前校验请求正文]]。

结构图:

flowchart TD
 A[收到响应] --> B[检查状态码和响应头]
 B --> C[查找必需结构]
 C --> D[检查字段类型与业务取值]
 D --> E{满足当前任务前提}
 E -->|是| F[计算并构造请求]
 E -->|否| G[拒绝业务处理并报告]
这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体客户端 · 查看原书依据

      API client applications should inspect incoming service responses on three levels: Protocol Does the response include the expected HTTP protocol-level details (HTTP status code, content-type, and any other important headers)? Structure Is the response body (if it exists) made up of the expected structural elements? For example, is there an expected title property? Does the body contain one or more link elements with the expected rel, name, or other properties, and so forth?

    参考来源

    - 位置:《RESTful Web API Patterns and Practices Cookbook》第4章《Hypermedia Clients》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch04.xhtml,配方4.13) - 结论依据:原文按Protocol、Structure、Value组织入站检查,用税额计算示例说明检查先于业务处理。 - 原始内容:API client applications should inspect incoming service responses on three levels: Protocol Does the response include the expected HTTP protocol-level details (HTTP status code, content-type, and any other important headers)? Structure Is the response body (if it exists) made up of the expected structural elements? For example, is there an expected title property? Does the body contain one or more link elements with the expected rel, name, or other properties, and so forth?