0

我有一个使用清洗创建的 SOAP Web 服务,该服务具有一个带有 base64Binary 类型参数的操作(我假设它相当于 C# 中的 byte[])。

我将以下变量发送到我的 Web 服务参数:

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
4

1 回答 1

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吧。

于 2013-02-04T22:52:03.090 回答