SOAP 1.2 XMLのContent-Type(actionパラメータ付き)
actionパラメータ付きSOAP 1.2 Webサービスリクエスト用のContent-Typeヘッダーを設定します。application/soap+xmlとtext/xmlの違いを解説します。
XML/SOAP
詳細な説明
SOAP 1.2 Content-Type
SOAP 1.2は、SOAP 1.1で使用されていたtext/xmlに代わり、メディアタイプとしてapplication/soap+xmlを使用します。actionパラメータはWebサービスで呼び出すオペレーションを指定します。
ヘッダー値
Content-Type: application/soap+xml; charset=utf-8; action="http://example.com/CalculatePrice"
SOAP 1.1と1.2の比較
| 特徴 | SOAP 1.1 | SOAP 1.2 |
|---|---|---|
| Content-Type | text/xml |
application/soap+xml |
| Action | SOAPAction HTTPヘッダー | Content-Typeのactionパラメータ |
| デフォルトcharset | US-ASCII | UTF-8 |
SOAP 1.1の例
レガシーSOAP 1.1サービスの場合、別のSOAPActionヘッダーを使用します:
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.com/CalculatePrice"
SOAP 1.2リクエストボディ
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<CalculatePrice xmlns="http://example.com/">
<item>Widget</item>
<quantity>5</quantity>
</CalculatePrice>
</soap:Body>
</soap:Envelope>
curlの例
curl -X POST \
-H 'Content-Type: application/soap+xml; charset=utf-8; action="http://example.com/CalculatePrice"' \
-d @request.xml \
https://service.example.com/soap
ユースケース
エンタープライズシステム、銀行API、政府サービスで一般的なSOAP 1.2 Webサービスとの統合時に使用します。多くの.NET WCFおよびJava JAX-WSサービスがSOAP 1.2を使用しています。