2

適切なSOAPヘッダーを作成しようとしています。

<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sen="https://webservices.averittexpress.com/SendWebImageService">
<soapenv:Header
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns:authnHeader
soapenv:mustUnderstand="0"
xmlns:ns="http://webservices.averittexpress.com/authn">
<Username>xxxxxxxx</Username> <Password>xxxxxxxx</Password>
</ns:authnHeader> </soapenv:Header>

これは私のSavonクライアント呼び出しです。バージョン2を使用しています。

client = Savon.client(
  wsdl: api_url,
  raise_errors: false,
  convert_request_keys_to: :camelcase,
  element_form_default: :qualified,
  env_namespace: :soapenv,
  soap_header: {'username' => username, 'password' => password }
)

次のSOAPエラーが発生します。

fault=>
  {:faultcode=>"soapenv:Server",
  :faultstring=>"java.lang.NullPointerException",
  :detail=>nil}}

どうすればsapoenv:mustUserstand="0"ラインを取得できますか?それは何ですか?

さらに、の設定方法がわかりませんxmlns:ns="http://webservices.averittexpress.com/authn">

私はSOAPリクエストの使用経験がほとんどなく、Ruby /RailsRESTfulバックグラウンドから来ています。どんな助けでもいただければ幸いです。

4

1 に答える 1

4

SavonはGyokuを使用して、SOAPヘッダーと本文の両方をXMLに変換します。
このライブラリの規則に従って、ハッシュは次のようになります。

soap_header = {
  "ns:authnHeader" => {
    "@soapenv:mustUnderstand" => 0,
    "@xmlns:ns" => "http://webservices.averittexpress.com/authn",
    "Username"  => "x",
    "Password"  => "x"
  }
}

Savon.client(:soap_header => soap_header)
于 2013-01-15T20:50:08.443 に答える