soap soapenv SOAP-ENV 區別


soap soapenv SOAP-ENV 區別

請求代碼

<?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>
  <helloWorldResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <helloWorldReturn xsi:type="xsd:string">Hello World! This  is Test!</helloWorldReturn>
  </helloWorldResponse>
 </soapenv:Body>
</soapenv:Envelope>

 

有時soapevn 是大寫: SOAP-ENV,這完全是命名空間的定義

這個屬於XML基礎知識。
帶有冒號的xml標簽用於聲明xml的標簽元素的命名空間。

為什么要使用命名空間呢?這是因為XML文檔中同一個標簽名可能有着不同的含義。例如<table>這個標簽,一般我們知道它是一個網頁上的表格,如果一個家具商,它當然認為這表示一張桌子了。有時即使是在一個XML文件內也可能有這樣的命名沖突。因此XML規范制定者們引入了名字空間的概念。具體做法就是先用xmlns:xxx 聲明一個命名空間,這樣在標簽的前面加個前綴並與標簽本身的名字用冒號隔開。這就是SOAP的XML文本中冒號和xmlns滿天飛的由來。

這個前綴soapenv 應該而且只需要與xmlns:后面的東西完全一樣。換句話說。你可以叫soapenv 也可以叫SOAP-ENV或其他任何你喜歡的名字,但后面的 xmlns:xxx=yyyy這個xxx也必須叫這個名字。后面的這個yyyy可是固定的內容。
XML規范還規定了,命名空間是向下包含的。除非特別另外聲明,子節點的命名空間默認就是它的父節點的命名空間,這樣可以減少書寫的麻煩。

擴展

** 什么是 SOAP? **

SOAP 指簡易對象訪問協議
SOAP 是一種通信協議
SOAP 用於應用程序之間的通信
SOAP 是一種用於發送消息的格式
SOAP 被設計用來通過因特網進行通信
SOAP 獨立於平台
SOAP 獨立於語言
SOAP 基於 XML
SOAP 很簡單並可擴展
SOAP 允許您繞過防火牆
SOAP 將被作為 W3C 標准來發展
** 語法規則 **

SOAP 消息必須用 XML 來編碼
SOAP 消息必須使用 SOAP Envelope 命名空間
SOAP 消息必須使用 SOAP Encoding 命名空間
SOAP 消息不能包含 DTD 引用
SOAP 消息不能包含 XML 處理指令
** SOAP消息舉例 **

請求

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://service.zlb.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <q0:sayHello>
      <arg0>hello</arg0>
    </q0:sayHello>
  </soapenv:Body>
</soapenv:Envelope>

響應

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:sayHelloResponse xmlns:ns2="http://service.zlb.com/">
<return>hello hello</return>
</ns2:sayHelloResponse>
</soap:Body>
</soap:Envelope>

 

soap和soapenv xml例子

soap是這樣的:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
    <soap:Header/>
    <soap:Body>
        <tem:BillnoteClipInitialization>
            <tem:json>
            {}
            </tem:json>
        </tem:BillnoteClipInitialization><!--  -->
    </soap:Body>
</soap:Envelope>

soapenv是這樣的:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
    <soapenv:Header/>
    <soapenv:Body>
        <tem:BillnoteClip>
            <tem:json>
            {}
            </tem:json>
            <tem:type>set</tem:type>
        </tem:BillnoteClip>
    </soapenv:Body>
</soapenv:Envelope>

 

參考文章:

https://blog.csdn.net/enetor1/article/details/40856897

https://www.jianshu.com/p/c3ef663c6101

https://blog.csdn.net/enthan809882/article/details/103941858


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM