Soap-transport

提供:Dev Guides
移動先:案内検索

SOAP-トランスポート

SOAPはどのトランスポートプロトコルにも関連付けられていません。 SOAPは、SMTP、FTP、IBMのMQSeries、またはMicrosoft Message Queuing(MSMQ)を介して転送できます。

SOAP仕様には、HTTPに関する詳細のみが含まれています。 HTTPは依然として最も人気のあるSOAPトランスポートプロトコルです。

HTTP経由のSOAP

かなり論理的に、SOAPリクエストはHTTPリクエストを介して送信され、SOAPレスポンスはHTTPレスポンスのコンテンツ内で返されます。 SOAPリクエストはHTTP GETを介して送信できますが、仕様にはHTTP POSTのみの詳細が含まれます。

また、コンテンツタイプをtext/xmlに設定するには、HTTPリクエストとレスポンスの両方が必要です。

SOAP仕様では、クライアントは_SOAPActionヘッダーを提供する必要がありますが、SOAPActionヘッダーの実際の値はSOAPサーバーの実装に依存しています。

たとえば、XMethodsがホストするAltaVista BabelFish Translationサービスにアクセスするには、SOAPActionヘッダーとして次を指定する必要があります。

urn:xmethodsBabelFish#BabelFish

サーバーが完全なSOAPActionヘッダーを必要としない場合でも、クライアントは空の文字列( "")またはnull値を指定する必要があります。 たとえば-

SOAPAction: ""
SOAPAction:

これは、HTTP経由でXMethods Babelfish翻訳サービスに送信されるサンプルリクエストです-

POST/perl/soaplite.cgi HTTP/1.0
Host: services.xmethods.com
Content-Type: text/xml; charset = utf-8
Content-Length: 538
SOAPAction: "urn:xmethodsBabelFish#BabelFish"

<?xml version = '1.0' encoding = 'UTF-8'?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
   xmlns:xsd = "http://www.w3.org/1999/XMLSchema">

   <SOAP-ENV:Body>
      <ns1:BabelFish
         xmlns:ns1 = "urn:xmethodsBabelFish"
         SOAP-ENV:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/">
         <translationmode xsi:type = "xsd:string">en_fr</translationmode>
         <sourcedata xsi:type = "xsd:string">Hello, world!</sourcedata>
      </ns1:BabelFish>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

コンテンツタイプとSOAPActionヘッダーに注意してください。 BabelFishメソッドには2つの文字列パラメーターが必要です。 翻訳モードen_frは、英語からフランス語に翻訳します。

XMethodsからの応答は次のとおりです-

HTTP/1.1 200 OK
Date: Sat, 09 Jun 2001 15:01:55 GMT
Server: Apache/1.3.14 (Unix) tomcat/1.0 PHP/4.0.1pl2
SOAPServer: SOAP::Lite/Perl/0.50
Cache-Control: s-maxage = 60, proxy-revalidate
Content-Length: 539
Content-Type: text/xml

<?xml version = "1.0" encoding = "UTF-8"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding/"
   SOAP-ENV:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
   xmlns:xsi = "http://www.w3.org/1999/XMLSchema-instance"
   xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsd = "http://www.w3.org/1999/XMLSchema">

   <SOAP-ENV:Body>
      <namesp1:BabelFishResponse xmlns:namesp1 = "urn:xmethodsBabelFish">
         <return xsi:type = "xsd:string">Bonjour, monde!</return>
      </namesp1:BabelFishResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

HTTP経由で配信されるSOAP応答は、同じHTTPステータスコードに従う必要があります。 たとえば、200 OKのステータスコードは、成功した応答を示します。 500内部サーバーエラーのステータスコードは、サーバーエラーがあり、SOAP応答にFault要素が含まれていることを示します。