我正在使用savon gem访问abc金融web服务。我收到用户未授权的错误消息。我正在使用此代码来访问响应
@wsdl="https://webservice.abcfinancial.com/wsdl/Prospect.wsdl"
@basic_auth=["user","pass"]
@headers={"Authorization" => "Basic"}
@client = Savon.client do |globals|
globals.wsdl @wsdl
globals.basic_auth @basic_auth
globals.headers @headers
end
@message = {
:clubNumber=> 'Club 0233',
:firstName=> 'abc',
:lastName=> 'def',
:gender=> "male"
}
response = @client.call(:insert_prospect, message: @message)我收到了一条错误消息user not authorize。我搜索了它,但没有找到任何解决方案。请帮帮我。
发布于 2014-08-05 02:01:24
他们正在使用JAX-WS。根据本文http://examples.javacodegeeks.com/enterprise-java/jws/application-authentication-with-jax-ws/ (和谷歌)的说法,我们应该在http报头中使用登录密码。我在http://abcfinancial.com上没有帐户,所以我不能测试代码。试试看:
require 'savon'
user = 'myLogin'
password = 'myPassword'
client = Savon.client(
wsdl: 'https://webservice.abcfinancial.com/wsdl/Prospect.wsdl',
headers: {username: user,
password: password},
pretty_print_xml: true,
log: true
)
message = {
:arg0 => {
clubNumber: 'Club 0233',
:personal => {
:firstName => 'myName',
:lastName => 'myLastName',
:gender => 'male'
}
}
}
response = client.call(:insert_prospect, message: message)阅读这篇好文章日志并打开调试(pretty_print_xml: true,http://predic8.com/wsdl-reading.htm:true)。
https://stackoverflow.com/questions/22908485
复制相似问题