我正在尝试了解Railscast: SOAP with Savon并为我的方案实施它。
我在rails console
realm = Base64.strict_encode64("user:password")
client = Savon.client(wsdl: "http://xxxxx?wsdl", soap_header: { 'Authorization:' => "Basic #{realm}"}, log: true, log_level: :debug, pretty_print_xml: true)
message = {"X1" => "XX", "X2" => 108539, "X3" => 2, "CONFIRM" => TRUE}
到目前为止一切都很好。以下行引发错误
response = client.call(:update_job, message: message)
请您告诉我如何解决以下错误或任何有用的文档,我可以查看以修复错误。 (我尝试过在线搜索,还查看了http://savonrb.com/version2/requests.html)
HTTPI POST request to sit (net_http)
SOAP response (status 500)
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd=
"http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Unexpected character '>' (code 62) (expected a name start
character)
at [row,col {unknown-source}]: [1,434]</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Savon::SOAPFault: (soap:Server) Unexpected character '>' (code 62) (expected a n
ame start character)
at [row,col {unknown-source}]: [1,434]
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/savon-2.6.0/lib/savon/res
ponse.rb:85:in `raise_soap_and_http_errors!'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/savon-2.6.0/lib/savon/res
ponse.rb:14:in `initialize'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/savon-2.6.0/lib/savon/ope
ration.rb:64:in `create_response'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/savon-2.6.0/lib/savon/ope
ration.rb:55:in `call'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/savon-2.6.0/lib/savon/cli
ent.rb:36:in `call'
from (irb):75:in `evaluate'
from org/jruby/RubyKernel.java:1101:in `eval'
from org/jruby/RubyKernel.java:1501:in `loop'
from org/jruby/RubyKernel.java:1264:in `catch'
from org/jruby/RubyKernel.java:1264:in `catch'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/railties-3.2.13/lib/rails
/commands/console.rb:47:in `start'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/railties-3.2.13/lib/rails
/commands/console.rb:8:in `start'
from c:/jruby-1.7.12/lib/ruby/gems/shared/gems/railties-3.2.13/lib/rails
/commands.rb:41:in `(root)'
from org/jruby/RubyKernel.java:1065:in `require'
from script/rails:6:in `(root)'
感谢。
答案 0 :(得分:0)
您的soap_header不应带有:
(Authorization:
)的后缀。
client = Savon.client(
wsdl: "http://xxxxx?wsdl",
soap_header: { 'Authorization' => "Basic #{realm }"},
log: true,
log_level: :debug,
pretty_print_xml: true
)