我正在使用最新版本的savon gem,并试图发送SOAP请求,我收到了有关无效url的错误消息:
 Invalid URL: %7Bendpoint%20address%7D (ArgumentError)
        from /home/vagrant/.rvm/gems/ruby-2.1.0/gems/httpi-2.3.0/lib/httpi/request.rb:27:in `url='
        from /home/vagrant/.rvm/gems/ruby-2.1.0/gems/savon-2.8.0/lib/savon/operation.rb:103:in `build_request'
        from /home/vagrant/.rvm/gems/ruby-2.1.0/gems/savon-2.8.0/lib/savon/operation.rb:51:in `call'
        from /home/vagrant/.rvm/gems/ruby-2.1.0/gems/savon-2.8.0/lib/savon/client.rb:36:in `call'我的代码是:
require "savon"
require "excon"
Excon.defaults[:ssl_verify_peer] = false
class Payback
  attr_reader :connection, :client, :operation, :message
  SOAP_URL = "https://partnertest.payback.in/PBExternalServices/v1/soap?wsdl"
  def initialize operation, message
    @client = Savon.client(wsdl: "https://partnertest.payback.in/PBExternalServices/v1/soap?wsdl", ssl_verify_mode: :none)
    @operation = operation
    @message = message
  end
  def response
    @response ||= client.call(operation, message: message)
  end
end这就是我使用它的方式。(,我知道名称空间有问题)
payback = Payback.new :get_account_balance,
                      {"typ:Authentication" => { "typ1:Principal" => { "typ1:PrincipalValue" => 9899012182,
                                                                       "typ1:PrincipalClassifier" => 3 }}}
payback.response我需要用savon构造这个XML。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://www.payback.net/lmsglobal/ws/v1/extint/types" xmlns:typ1="http://www.payback.net/lmsglobal/xsd/v1/types">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:GetAccountBalanceRequest>
         <typ:Authentication>
            <typ1:Principal>
               <typ1:PrincipalValue>9899012182</typ1:PrincipalValue>
               <typ1:PrincipalClassifier>3</typ1:PrincipalClassifier>
            </typ1:Principal>
         </typ:Authentication>
      </typ:GetAccountBalanceRequest>
   </soapenv:Body>
</soapenv:Envelope>我不知道我做错了什么,请帮帮忙。
发布于 2015-01-05 10:25:24
我注意到,在WSDL文件的第5820行中,位置如下所示:
<soap:address location="{endpoint address}"/>会不会是问题所在?
编辑1。
{endpoint address}字符串。我很难理解这个特定的WSDL文档,但是我想知道是否一定有其他的东西来代替{endpoint address},比如一个真正的URI。例如,会不会是WSDL文档有问题?
编辑2
尝试删除服务未识别的typ和typ1。最后得到一个返回有效响应的工作代码:
puts Savon.client(
  wsdl: 'https://partnertest.payback.in/PBExternalServices/v1/soap?wsdl',
  endpoint: 'https://partnertest.payback.in/PBExternalServices/v1/soap',
  ssl_verify_mode: :none
).call(
  :get_account_balance,
  :message => {
    'Authentication' => {
      'Principal' => {
        'PrincipalValue' => 9899012182,
        'PrincipalClassifier' => 3
      }
    }
  }
)https://stackoverflow.com/questions/27774764
复制相似问题