2016-04-21 90 views
0

我試圖連接到已經使用PHP NuSoap庫設置的遠程SOAP服務。我正在使用Ruby Savon客戶端進行連接。使用Ruby Savon客戶端連接到PHP NuSOAP服務器

訪問該服務的WDSL地址(http://example.com/api/webservice.php?wdsl)給出了關於終點,我嘗試使用以下信息:

Name: addsubscription 
    Binding: webserviceBinding 
    Endpoint: http://www.example.com/api/webservice.php 
    SoapAction: http://www.example.com/api/webservice.php/addsubscription 
    Style: rpc 
    Input: 
    use: encoded 
    namespace: 
    encodingStyle: http://schemas.xmlsoap.org/soap/encoding/ 
    message: addsubscriptionRequest 
    parts: 
    Output: 
    use: encoded 
    namespace: 
    encodingStyle: http://schemas.xmlsoap.org/soap/encoding/ 
    message: addsubscriptionResponse 
    parts: 
    Namespace: 
    Transport: http://schemas.xmlsoap.org/soap/http 
    Documentation: 

設置我的薩翁客戶像這樣:

client = Savon::Client.new(wsdl: "http://www.example.com/api/webservice.php?wdsl") 

和然後嘗試調用「添加訂閱」方法:

response = client.call(:addsubscription) do 
    message my_hash_of_stuff 
end 

gi VES在日誌下面的錯誤 -

Savon::UnknownOperationError: Unable to find SOAP operation: :addsubscription 
Operations provided by your service: [] 

設置客戶端,像這樣:

client = Savon.client do 
    endpoint "http://www.example.com/api/webservice.php" 
    namespace '' 
end 

,然後運行相同的呼叫如上提出了薩翁::的SOAPFault錯誤,這我假設是由於缺乏名稱空間屬性(我不知道如何進一步調試/收集此錯誤中的信息)?

根據以上信息,我應該如何配置Savon客戶端連接到此服務?

編輯:

設置客戶機像這樣 -

client = Savon.client(namespace: '', endpoint: 'http://www.example.com/api/webservice.php') 

,然後調用(用填充message_hash VAR)

response = client.call(:addsubscription, 
        message: message_hash) 

吐出以下錯誤:

Savon::SOAPFault: /app/vendor/bundle/ruby/2.2.0/gems/nori-2.6.0/lib/nori.rb:72:in `find_value': undefined method `each' for nil:NilClass (NoMethodError) 
from /app/vendor/bundle/ruby/2.2.0/gems/nori-2.6.0/lib/nori.rb:38:in `find' 
from /app/vendor/bundle/ruby/2.2.0/gems/savon-2.11.1/lib/savon/soap_fault.rb:24:in `to_s' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:498:in `write' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:498:in `print' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:498:in `block (2 levels) in eval_input' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:623:in `signal_status' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:486:in `block in eval_input' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb/ruby-lex.rb:245:in `block (2 levels) in each_top_level_statement' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `loop' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb/ruby-lex.rb:231:in `block in each_top_level_statement' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `catch' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb/ruby-lex.rb:230:in `each_top_level_statement' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:485:in `eval_input' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:395:in `block in start' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:394:in `catch' 
from /app/vendor/ruby-2.2.3/lib/ruby/2.2.0/irb.rb:394:in `start' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>' 
from /app/bin/rails:4:in `require' 
from /app/bin/rails:4:in `<main>' 
+0

我以爲你不是真的* *調用'HTTP://www.example.com/api/webservice.php wdsl',你?那只是你的佔位符? –

+0

另外:如果你打開登錄你的Savon客戶端,你可能會得到更好的信息,哪裏出了問題。 WSDL是怎樣的?您發佈的內容不是WSDL,而是其他一些僞代碼(?)文檔。我只注意到文檔中有一個'style:rpc',暗示它不是SOAP? –

回答

0

它看起來像你在過時的薩翁版本< 2.x.我建議升級到版本2.x(2.11.1,因爲我正在寫)。隨着v2的推出,界面發生了很大變化。

最小實現看起來是這樣的:

require 'savon' 

WSDL = 'http://www.example.com/api/webservice.php?wdsl' 

client = Savon.client(wsdl: WSDL, 
         log: true, 
         log_level: :debug, 
         pretty_print_xml: true) 
response = client.call(:addsubscription, 
         message: my_hash_of_stuff) 
print response.to_hash 
+0

感謝您的建議,根據我的Gemfile.lock使用了2.11.1,我從這裏的文檔中提取信息 - http://savonrb.com/version2/client.html - 我已經通過更多的信息更新了這個問題 – user2013350

+0

關於這方面的任何消息? –

相關問題