Ich verwende die neueste Version von savon
Juwel und versuchen, eine SOAP-Anfrage zu senden Ich erhalte diesen Fehler über ungültige 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"
Mein Code ist:
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
So benutze ich es. (Ich weiß, dass mit Namespaces etwas nicht stimmt)
payback = Payback.new :get_account_balance,
{"typ:Authentication" => { "typ1:Principal" => { "typ1:PrincipalValue" => 9899012182,
"typ1:PrincipalClassifier" => 3 }}}
payback.response
Ich muss dieses XML mit konstruieren savon
<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>
Ich weiß nicht, was ich hier falsch mache, bitte helfen Sie.
Antworten:
1 für die Antwort № 1Mir ist aufgefallen, dass in Zeile 5820 der WSDL-Datei der Speicherort so aussieht:
<soap:address location="{endpoint address}"/>
Könnte es das Problem sein?
Bearbeitet 1.
- Öffnen Sie in Ihrem Browser: https://partnertest.payback.in/PBExternalServices/v1/soap?wsdl
- Suchen nach
{endpoint address}
Zeichenfolge auf der Seite.
Ich bin weit davon entfernt, dieses spezielle WSDL - Dokument zu verstehen, aber ich frage mich, ob es an Stelle von etwas anderem etwas geben muss {endpoint address}
, wie eine echte URI. Z.B. könnte es das WSDL-Dokument sein, das das Problem hat?
Bearbeitet 2
Versuchte das zu entfernen typ
und typ1
die vom Service nicht erkannt wurden. Endete mit einem Arbeitscode, der eine gültige Antwort zurückgibt:
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
}
}
}
)