2

Savonを使用してRubyでSOAPリクエストを作成しようとしていますが、サーバーから400BadRequestレスポンスを受信して​​います。

これは私が行おうとしているリクエストです(soapUIによると):

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:apis="http://www.csisoftwareusa.com/ApiService">    
    <soap:Header/>    
    <soap:Body>
      <apis:AuthenticateConsumer>
         <!--Optional:-->
         <apis:consumerName>?</apis:consumerName>
         <!--Optional:-->
         <apis:consumerPassword>?</apis:consumerPassword>
      </apis:AuthenticateConsumer>    
    </soap:Body> 
</soap:Envelope>

これが私がRubyで行うリクエストです。400BadRequestエラーを返します。

<SOAP-ENV:Envelope>
  <SOAP-ENV:Body>
    <ins0:AuthenticateConsumer>
      <ins0:consumerName>?</ins0:consumerName>
      <ins0:consumerPassword>?</ins0:consumerPassword>
    </ins0:AuthenticateConsumer>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Http Headers: SOAPAction: "http://www.csisoftwareusa.com/ApiService/AuthenticateConsumer", Content-Type: text/xml;charset=UTF-8, Content-Length: 504

これが私がPythonで作成できたリクエストです。このリクエストは成功します:

<SOAP-ENV:Envelope>
  <SOAP-ENV:Header/>
  <ns0:Body>
    <ns1:AuthenticateConsumer>
      <ns1:consumerName>?</ns1:consumerName>
      <ns1:consumerPassword>?</ns1:consumerPassword>
    </ns1:AuthenticateConsumer>
  </ns0:Body>
</SOAP-ENV:Envelope>
Http headers: {'SOAPAction': u'"http://www.csisoftwareusa.com/ApiService/AuthenticateConsumer"', 'Content-Type': 'text/xml; charset=utf-8'}

このAPIへの呼び出しをRailsアプリケーションに統合する必要があるため、Pythonでそれを行うことは有効なソリューションではありません。

私が欠けているものを誰かが見ることができるかどうか疑問に思います。空の<SOAP-ENV:Header />タグが問題ですか?もしそうなら、どうすればそれをSavonリクエストに追加できますか?

ありがとう、スチュアート

4

2 に答える 2

0

ここでの問題は、http ヘッダーにあります。URL にスペースが含まれているため、URL をエンコードする必要があります。ただし、Savon に渡す前にエンコードする必要があります。Savon は再度エンコードします。この二重エンコードされた URL は失敗します。参照: https://stackoverflow.com/questions/14482251/ruby-savon-soap-request-double-escapes-spaces-in-url

ありがとう、スチュアート

于 2013-01-23T17:11:35.957 に答える