1

私はSavon v1でこのコードを持っていました:

client = Savon.client("http://www.server.com:9191/soapserver?wsdl")
service = client.request :get_authentication do
  client.http.headers["username"] = "myuser"
  client.http.headers["password"] = "mypass"
end

savon v2.3.0 へのアップデート後、再翻訳がうまくいきません。それは次のようなものでなければなりません

client = Savon.client do
  wsdl "http://www.shab.ch:9191/soapserver?wsdl
end
service = client.call(:get_authentication, {username: "myuser", password: "mypass"})`

しかし、行service = client.call(..." は機能しません。何か考えはありますか?

4

3 に答える 3

3

あなたがやりたいことは次のとおりだと思います:

gem "savon"
require "savon", "~>2.0"
...
client = Savon.client(headers: { username: "user", password: "password"},
                      wsdl: "http://www.example.com/?wsdl",
                      log: true,
                      log_level: :debug,
                      pretty_print_xml: true
                      #, and more options here if necessary)

これにより、キーと値のペアが http ヘッダーに挿入されます。

于 2013-10-02T18:01:17.437 に答える