簡體   English   中英

Wash_out gem錯誤訪問soap_config方法

[英]wash_out gem error accessing soap_config method

我無法從使用wash_out gem創建的SOAP服務中獲取xml響應。 現在,我只想要一個肥皂響應,如清洗示例代碼中那樣將整數轉換為字符串。 有任何想法我在這里做錯了嗎?

我的控制器代碼是:

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

服務器使用以下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>

肥皂客戶端發送以下消息:

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

服務器失敗,並出現以下內部錯誤:

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'

為了詳細說明我的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

這意味着wash_out發現控制器錯誤。

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

確保寶石發現控制器正確。

您的控制器代碼為:

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

正確的cofing / routes.rb代碼為:

wash_out "Api::Accounts"

上面的代碼在0.9.2版中有效。

版本0.10.0,您可以執行以下操作:

wash_out :accounts, module: "Api"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM