Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用ruby、json/nancy和C发布数据#_C#_Ruby On Rails_Ruby_Json_Nancy - Fatal编程技术网

C# 使用ruby、json/nancy和C发布数据#

C# 使用ruby、json/nancy和C发布数据#,c#,ruby-on-rails,ruby,json,nancy,C#,Ruby On Rails,Ruby,Json,Nancy,我在一个金融网站上工作,部分功能将是账户之间的转账。我们最初使用RubyonRails引用数据库中的存储过程来开发它。由于需要开发移动应用程序,我们现在转向json/nancy。我对获取数据没问题,但post证明更难 以下是控制器代码: post :index do begin amount = params[:amount].to_f from = @customer.fetch_account(params[:from].to_i) to = @customer.fetch_a

我在一个金融网站上工作,部分功能将是账户之间的转账。我们最初使用RubyonRails引用数据库中的存储过程来开发它。由于需要开发移动应用程序,我们现在转向json/nancy。我对获取数据没问题,但post证明更难

以下是控制器代码:

post :index do
begin

  amount = params[:amount].to_f
  from = @customer.fetch_account(params[:from].to_i)
  to = @customer.fetch_account(params[:to].to_i)

  if from.account_id == to.account_id
    flash[:error]= 'Cannot transfer funds to same account'
  else
    response = post_call('/Accounts/InternalXfer', { 
    :FromAccountID => 42,
    :ToAccountID => 643,
    :ToAccountTypeID => 2,
    :Amount => 200})

    if result.first.empty?
      raise
    end
    r = result.first
    if r.nil?
      raise 
    elsif r['Value'].to_s.eql? 'Error'
      flash[:error] = r['Message'].to_s
    elsif r['Value'].to_s.eql? 'Success'
      flash[:notice] = r['Message'].to_s
    else
      flash[:error] = r.to_s
    end
  end
  rescue
    flash[:error]= 'Something went wrong'
end
  redirect to('/transfers')
end
以下是c#代码:

我还包括以下用于调试的内容:

http.set_debug_output $stderr
其输出为:

opening connection to 10.10.10.27...
opened
<- "POST /Accounts/InternalXfer HTTP/1.1\r\nAccept: */*\r\nUser-Agent: Ruby\r\nC                    ontent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nHost: 10.                    10.10.27:7820\r\nContent-Length: 61\r\n\r\n"
<- "FromAccountID=42&ToAccountID=643&ToAccountTypeID=2&Amount=200"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: private\r\n"
-> "Content-Type: text/html\r\n"
-> "Server: Microsoft-IIS/8.0\r\n"
-> "X-AspNet-Version: 4.0.30319\r\n"
-> "X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcZWFtb25ubWNcRG9jdW1lbnRzXFZpc3VhbCBTdHV                    kaW8gMjAxMlxQcm9qZWN0c1xBYmFjdXNfSUJfTW9iaWxlXEFiYWN1c0lCLlNlcnZpY2VzXEFjY291bnR                    zXEludGVybmFsWGZlcg==?=\r\n"
-> "X-Powered-By: ASP.NET\r\n"
-> "Date: Thu, 09 Jul 2015 08:47:41 GMT\r\n"
-> "Connection: close\r\n"
-> "Content-Length: 1\r\n"
-> "\r\n"
reading 1 bytes...
-> "0"
read 1 bytes
Conn close
  DEBUG -  SERVICE - POST (0.0300s) /Accounts/InternalXfer
打开与10.10.10.27的连接。。。
开的
“缓存控制:专用\r\n”
->“内容类型:text/html\r\n”
->“服务器:Microsoft IIS/8.0\r\n”
->“X-AspNet-Version:4.0.30319\r\n”
->“X-SourceFiles:=?UTF-8?B?QzpcVXNlcnNcZWFtb25ubWNcRG9jdW1lbnRzXFZpc3VhbCBTdHV KAW8GMJAXMLXQCM9QZWn0C1XbymfjdxNFSUJFTW9IAWxlXefyWN1C0LCLLCNZY2VZXefJY291BNR zXEludGVybmFsWGZlcg==?\r\n”
->“X-Powered-By:ASP.NET\r\n”
->日期:2015年7月9日星期四08:47:41 GMT\r\n
->“连接:关闭\r\n”
->“内容长度:1\r\n”
->“\r\n”
正在读取1字节。。。
-> "0"
读取1字节
控制室关闭
调试-服务-发布(0.0300s)/帐户/InternalXfer

有人能告诉我哪里做错了,我遗漏了什么,或者我需要进一步调试,这样我才能理解如何进行调试。

你得到的实际错误是什么?@Christian Horsdal那里似乎没有错误,只是数据没有被发布到数据库中。奇怪的是,它在同事的电脑上工作,所以我想这可能是我电脑的配置。奇怪的是,这种方法正在发挥作用。
http.set_debug_output $stderr
opening connection to 10.10.10.27...
opened
<- "POST /Accounts/InternalXfer HTTP/1.1\r\nAccept: */*\r\nUser-Agent: Ruby\r\nC                    ontent-Type: application/x-www-form-urlencoded\r\nConnection: close\r\nHost: 10.                    10.10.27:7820\r\nContent-Length: 61\r\n\r\n"
<- "FromAccountID=42&ToAccountID=643&ToAccountTypeID=2&Amount=200"
-> "HTTP/1.1 200 OK\r\n"
-> "Cache-Control: private\r\n"
-> "Content-Type: text/html\r\n"
-> "Server: Microsoft-IIS/8.0\r\n"
-> "X-AspNet-Version: 4.0.30319\r\n"
-> "X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcZWFtb25ubWNcRG9jdW1lbnRzXFZpc3VhbCBTdHV                    kaW8gMjAxMlxQcm9qZWN0c1xBYmFjdXNfSUJfTW9iaWxlXEFiYWN1c0lCLlNlcnZpY2VzXEFjY291bnR                    zXEludGVybmFsWGZlcg==?=\r\n"
-> "X-Powered-By: ASP.NET\r\n"
-> "Date: Thu, 09 Jul 2015 08:47:41 GMT\r\n"
-> "Connection: close\r\n"
-> "Content-Length: 1\r\n"
-> "\r\n"
reading 1 bytes...
-> "0"
read 1 bytes
Conn close
  DEBUG -  SERVICE - POST (0.0300s) /Accounts/InternalXfer