2013-12-11 41 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 

的参数只是在键/值对的哈希值。