0

I have a SOAP web service created with washout that has an action with a parameter of type base64Binary(Which I assume is the equivalent of byte[] in C#).

I'm sending the following variable to my web service parameter:

file_data = Base64.encode64(File.binread("/path/to/my/file"))

It comes back with the error:

RuntimeError (Invalid WashOut simple type: base64Binary)

Am I not creating the datatype correctly from my file path?

Here is the controller for the web service:

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

Here is the code for my client:

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
James
  • 680
  • 2
  • 8
  • 22

1 Answers1

1

Where did you get :base64Binary? There is no such type for WSDL parameter:

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

Try :string instead.

  • Excuse my ignorance, I just happened to come across base64Binary when googling soap byte array. String works fine, thank you, I thought I needed different data type to represent a byte array like .NET uses byte[]. But based on your answer, it's probably safe to assume that the byte[] in .NET just ends up getting converted to a string some how when the request is made. – James Feb 04 '13 at 22:58