我试图用savon gem发送带有基本身份验证的soap请求
我的soap服务器是用wash_out gem设置的。
class OrdersController < ApplicationController
soap_service namespace: 'sir:WashOut', wsse_username: SIRA[:auth][:username], wsse_password: SIRA[:auth][:password] ……
当我通过savon向soap服务器发出请求时,会得到一个错误:
@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
soap_header: { 'Username' =>SIRA[:auth][:username], 'Password' => SIRA[:auth][:password] }
)
@response = @client.call(:notify ).to_hash在最后一个命令中,我得到一个错误
Savon::SOAPFault: (Server) Missing required UsernameToken发布于 2015-02-11 10:10:16
我试过了,而且成功了!
@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
wsse_auth: [SIRENA[:auth][:username], SIRENA[:auth][:password] ],
logger: Rails.logger
)
@response = @client.call(:notify, ).to_hash发布于 2015-07-18 11:49:18
client = Savon.client(
wsdl: 'http://service.example.com?wsdl',
soap_header: {
"AuthenticateRequest" =>
{"apiKey" => "****** your api *********"}},
pretty_print_xml: true)
client.operations
response = client.call(:function)
Note: "apiKey" is my prams to authenticate, your can be different发布于 2018-01-19 12:32:18
对于Savon 2,基本授权可以如下所示:
@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
basic_auth: ["username", "password"]
)
@response = @client.call(:notify ).to_hashhttps://stackoverflow.com/questions/28434493
复制相似问题