rails 使用 savon 通过 soap 基本身份验证
rails pass soap basic auth with savon
我正在尝试使用 savon gem
发送带有基本身份验证的 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
我试过了,很管用!
@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
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
对于Savon 2,基本授权可以如下进行:
@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
basic_auth: ["username", "password"]
)
@response = @client.call(:notify ).to_hash
我正在尝试使用 savon gem
发送带有基本身份验证的 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
我试过了,很管用!
@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
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
对于Savon 2,基本授权可以如下进行:
@client = Savon.client(
wsdl: "http://localhost:3000/orders/wsdl",
basic_auth: ["username", "password"]
)
@response = @client.call(:notify ).to_hash