我有一个使用flushout创建的SOAP Web服务,该服务的参数类型为base64Binary(我假设它相当于C#中的byte [])。
我将以下变量发送到我的网络服务参数:
file_data = Base64.encode64(File.binread("/path/to/my/file"))
它返回错误:
RuntimeError (Invalid WashOut simple type: base64Binary)
我是不是从文件路径中正确创建了数据类型?
以下是Web服务的控制器:
class ServiceController < ApplicationController
include WashOut::SOAP
soap_action "import_file",
:args => { :data => :base64Binary, :name => :string},
:return => :string
def import_file
render :soap => ("response")
end
# You can use all Rails features like filtering, too. A SOAP controller
# is just like a normal controller with a special routing.
before_filter :dump_parameters
def dump_parameters
Rails.logger.debug params.inspect
end
end
以下是我的客户的代码:
require 'savon'
class ServiceTester
def self.initiate
# create a client for your SOAP service
client = Savon.client do
wsdl "http://localhost:3000/service/wsdl"
end
file_data = Base64.encode64(File.binread("/path/to/my/file"))
response = client.call(:import_file, message: { data: file_data, name: "myfilename" })
end
end
答案 0 :(得分:1)
你从哪里得到:base64Binary
? WSDL参数没有这种类型:
operation = case type
when 'string'; :to_s
when 'integer'; :to_i
when 'double'; :to_f
when 'boolean'; nil
when 'date'; :to_date
when 'datetime'; :to_datetime
when 'time'; :to_time
else raise RuntimeError, "Invalid WashOut simple type: #{type}"
end
请尝试:string
。