简体   繁体   English

Wash_out gem错误访问soap_config方法

[英]wash_out gem error accessing soap_config method

I'm having trouble getting an xml response from my SOAP service created using the wash_out gem. 我无法从使用wash_out gem创建的SOAP服务中获取xml响应。 For now I just want a soap response that converts integer to string as done in the washout example code. 现在,我只想要一个肥皂响应,如清洗示例代码中那样将整数转换为字符串。 Any ideas what I'm doing wrong here? 有任何想法我在这里做错了吗?

My controller code is: 我的控制器代码是:

soap_service namespace: 'http://localhost:3000/api/accounts/wsdl'
soap_action "get_new_account",
          :args   => :integer,
          :return => :string
def get_new_account
render :soap => params[:value].to_s
end

The server responds with the following rpc wsdl: 服务器使用以下rpc wsdl进行响应:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost:3000/api/accounts/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="api_accounts" targetNamespace="http://localhost:3000/api/accounts/wsdl">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://localhost:3000/api/accounts/wsdl"></schema>
</types>
<portType name="api_accounts_port">
<operation name="get_new_account">
<input message="tns:get_new_account"/>
<output message="tns:get_new_account_response"/>
</operation>
</portType>
<binding name="api_accounts_binding" type="tns:api_accounts_port">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="get_new_account">
<soap:operation soapAction="get_new_account"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:3000/api/accounts/wsdl"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:3000/api/accounts/wsdl"/>
</output>
</operation>
</binding>
<service name="service">
<port name="api_accounts_port" binding="tns:api_accounts_binding">
<soap:address location="http://localhost:3000/api/accounts/action"/>
</port>
</service>
<message name="get_new_account">
<part name="value" type="xsd:int"/>
</message>
<message name="get_new_account_response">
<part name="value" type="xsd:string"/>
</message>
</definitions>

The soap client is sending the following message: 肥皂客户端发送以下消息:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <get_new_account xmlns="http://localhost:3000/api/accounts/wsdl">
            <value>123</value>
        </get_new_account>
    </Body>
</Envelope>

The server fails with the following internal error: 服务器失败,并出现以下内部错误:

Started POST "/api/accounts/action" for ::1 at 2016-04-22 11:29:10 -0400

NoMethodError (undefined method `soap_config' for AccountsController:Class):
  wash_out (0.9.2) lib/wash_out/router.rb:18:in `parse_soap_action'

To detail my rails environment I also include my Gemfile: 为了详细说明我的rails环境,我还包含了我的Gemfile:

source 'https://rubygems.org'

ruby '2.3.0'
#ruby-gemset=washout

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.2'
#ruby-gemset=washout

gem 'therubyracer'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'

# Use SCSS for stylesheets
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
gem 'sprockets-rails'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'utf8_enforcer_workaround'


gem 'autoprefixer-rails', '>= 5.2.1'
gem 'pg'

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
# gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Wash Out Soap Service
gem 'wash_out', '0.9.2'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
  gem 'annotate'
  gem 'rspec-rails'
  gem 'factory_girl_rails'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  gem 'capistrano'
  gem 'capistrano-bundler'
  gem 'capistrano-passenger'
  gem 'capistrano-rails'
  # gem 'capistrano-rvm' 
end

group :test do 
  gem 'faker', '1.4.2'
  gem 'capybara'
  gem 'selenium-webdriver'
  gem 'database_cleaner'
  gem 'guard-rspec'
  gem 'launchy'
end

This means that the wash_out found the controller is wrong. 这意味着wash_out发现控制器错误。

The gem source code(wash_out-0.9.2/lib/wash_out/router.rb): gem的源代码(wash_out-0.9.2 / lib / wash_out / router.rb):

class Router
  def initialize(controller_name)    # controller_name = "accounts"
    # @controller_name = AccountController
    # the controller maybe incorrect.
    @controller_name = "#{controller_name.to_s}_controller".camelize
  end
  ...
end

Ensure that the gem found the controller is correct. 确保宝石发现控制器正确。

Your controller code is: 您的控制器代码为:

class Api::AccountsController < ApplicationController
  soap_service namespace: 'http://localhost:3000/api/accounts/wsdl'
  soap_action "get_new_account",
      :args   => :integer,
      :return => :string
  def get_new_account
    render :soap => params[:value].to_s
  end
end

The right cofing/routes.rb code is: 正确的cofing / routes.rb代码为:

wash_out "Api::Accounts"

The above code is working in version 0.9.2. 上面的代码在0.9.2版中有效。

Version 0.10.0, you can do this: 版本0.10.0,您可以执行以下操作:

wash_out :accounts, module: "Api"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM