【SOAP】soap 协议小记

1、SOAP 是什么东西?

SOAP 是一种基于 XML 的协议,用于在网络上传输结构化的数据。在大多数情况下,SOAP 请求会被封装为 HTTP POST 请求进行发送。

SOAP 请求通常使用 HTTP 协议的 POST 方法将请求发送到 SOAP Web 服务的端点(通常是一个 URL)。请求的内容将以 XML 格式的 SOAP Envelope 发送到服务器。

与传统的 HTTP 请求相比,SOAP 请求需要在 HTTP 请求的 body 部分中包含一个表示 SOAP 消息的 XML 文档。这个 XML 文档描述了要调用的具体操作(方法)以及相关的参数。

在发送 SOAP 请求时,常见的做法是在 HTTP Headers 中添加一些特定的头信息,如 Content-Type 和 SOAPAction 来指定消息的类型和目标操作。这些头信息帮助服务器正确解析和处理 SOAP 请求。

所以,尽管 SOAP 是一种独立的协议,但它仍然依赖 HTTP 作为底层的通信协议来实现请求和响应的传输。


2、怎样用 Postman 去发送一个soap请求

HTTP, POST
Content-Type text/xml;charset=UTF-8

Body: 这个body要选择 raw, xml 的格式
然后,我们参数体是一个 xml, 但soap参数体,还要包一层。
即:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:xsd="http://www.w3.org/2001/XMLSchema"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <ns1:invoke soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"            xmlns:ns1="http://xxService.chinamobile.com">
            <xmlData xsi:type="soapenc:string"                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">${真正的XML参数}</xmlData>
        </ns1:invoke>
    </soapenv:Body>
</soapenv:Envelope>

大概是这样子。

posted @ 2023-07-07 14:02  aaacarrot  阅读(175)  评论(0编辑  收藏  举报