2013-12-11 39 views
0

我有一個WSDL URL給請求和響應拿到這是我的代碼(使用此薩翁寶石)薩翁寶石example_body不來正確

client = Savon.new('http://services.chromedata.com/Description/7a?wsdl') 
service = :Description7a 
port = :Description7aPort 
operation = :getDivisions 
division = client.operation(service, port, operation) 

我能夠打印example_body像 division.example_body

=> {:DivisionsRequest=>{:accountInfo=>{:_number=>"string", :_secret=>"string", :_country=>"string", :_language=>"string", :_behalfOf=>"string"}, :_modelYear=>"int"}} 

和我能夠設定的值等 division.body = {.........}

其他操作,例如像

operationlist = client.operations(service, port) 
=> ["getVersionInfo", "getModelYears", "getDivisions", "getSubdivisions", "getModels", "getStyles", "describeVehicle", "getCategoryDefinitions", "getTechnicalSpecificationDefinitions"] 

我用描述車輛

desc_veh = client.operation(service, port, "describeVehicle") 

其example_body就像

desc_veh.example_body 
=> {:VehicleDescriptionRequest=>{}} 

所以無法設置爲desc_veh.body和使用.CALL功能

I值不知道這是一個savon寶石問題還是wsdl url問題

回答

0

您的代碼看起來是這樣的:

gem "savon", "~> 2.0" 
require "savon" 
client = Savon.client(
    :wsdl => 'http://services.chromedata.com/Description/7a?wsdl', 
    :convert_request_keys_to => :camelcase, 
    :log => true, 
    :log_level => :debug, 
    :pretty_print_xml => true 
) 

res = client.call(:get_divisions, 
    message: { :param1 => 'value1', :param2 => 'value2' } 
) 

print res.to_hash 

的參數只是在鍵/值對的哈希值。