SOAP वेब सेवाएँ: Envelope, Header, Body और Fault पढ़ना
SOAP अलग-अलग transport पर संरचित संदेश भेजने का XML messaging framework है। यह लेख W3C SOAP 1.2 पर आधारित है और Envelope, Header, Body, Fault को HTTP binding से अलग समझाता है। SOAP message structure तय करता है, सभी application operations या security और reliability policies नहीं।
SOAP अलग-अलग transport पर संरचित संदेश भेजने का XML messaging framework है। यह लेख W3C SOAP 1.2 पर आधारित है और Envelope, Header, Body, Fault को HTTP binding से अलग समझाता है। SOAP message structure तय करता है, सभी application operations या security और reliability policies नहीं।
SOAP 1.2 message structure
SOAP message में ठीक एक Envelope root होता है। वैकल्पिक Header message path के nodes के लिए extension metadata रखता है; Body अंतिम receiver के लिए content रखता है। बीच के SOAP nodes अपने लिए बने headers process करके message आगे भेज सकते हैं। नीचे synthetic उदाहरण है; GetOrder और correlationId का अर्थ service contract तय करता है।
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ex="urn:example:orders">
<env:Header><ex:correlationId>req-7</ex:correlationId></env:Header>
<env:Body><ex:GetOrder><ex:orderId>42</ex:orderId></ex:GetOrder></env:Body>
</env:Envelope>mustUnderstand क्या माँगता है?
किसी node के लिए लक्षित Header block पर mustUnderstand="true" हो तो वह node उसे चुपचाप अनदेखा नहीं कर सकता। यदि वह block नहीं समझता, SOAP 1.2 MustUnderstand Fault और आगे processing रोकने की माँग करता है। Target role, namespace, version और header intermediary या अंतिम service के लिए है—यह जाँचें।
Fault और HTTP status साथ पढ़ें
SOAP 1.2 Fault में Code और Reason होते हैं और SOAP Fault semantics के लिए वह Body का अकेला child होना चाहिए; Node, Role, Detail वैकल्पिक हैं। Sender request-side समस्या और Receiver processing समस्या बता सकता है, पर यह सुरक्षित retry का प्रमाण नहीं।
SOAP को HTTP जैसे transport से bind किया जा सकता है। SOAP 1.2 HTTP binding अलग से परिभाषित है। इसके उपयोग में HTTP status और SOAP body साथ देखें; proxy error body बदल सकता है। केवल HTTP 200 business operation की सफलता साबित नहीं करता।
Integration checklist
SOAP 1.1 या 1.2 की पुष्टि करें; Envelope namespace अलग हैं।
WSDL या service contract से message type, operation, binding और endpoint ढूँढ़ें।
Media type, action, HTTP method, authentication और TLS को contract से मिलाएँ।
Extension header का namespace, target role और mustUnderstand व्यवहार देखें।
सामान्य Body response और Fault को अलग संभालें; status, Content-Type और body देखें।
Operation के side effects और deduplication नियम सुरक्षित बनाएँ तभी retry करें।
Untrusted XML के लिए अनावश्यक DTD और external entity resolution बंद करें और input सीमित रखें।
SOAP का उपयोग सभी implementations में समान method, schema, HTTP header या security extension की गारंटी नहीं देता। Deployed contract का पालन करें और client/server libraries की वास्तविक SOAP version व binding जाँचें।
स्रोत
[W3C SOAP 1.2 Part 1](https://www.w3.org/TR/soap12/)
[W3C SOAP 1.2 Part 2](https://www.w3.org/TR/soap12-part2/)
[OWASP XML External Entity Prevention](https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html)
[RFC 9110: HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html)