我C#应用程序和Node.js的代码之间的沟通? [英] Can I communicate between c# application and node.js code?

查看:242
本文介绍了我C#应用程序和Node.js的代码之间的沟通?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和node.js的没有经验,所以所以我需要澄清一些东西。

I have no experience with node.js, so therefore i need to clarify something.

我有一个 C#应用程序和< STRONG>的node.js 应用程序。我想按下一个按钮,在我的C#应用​​程序,并发送3个参数来使Node.js应用/功能作为输入。

I have a c# application and a node.js application. I would like to press on a button, in my c# application, and send 3 arguments to a node.js application/function as input.

这是可能的?(直线前进)

编辑:这两个应用程序在同一台机器上运行。 C#应用程序将提供3个参数来Node.js的应用程序。 Node.js的应用程序将查询的Web服务(POST),接受一些XML数据和处理这些数据。
我知道我能做到在C#中的任务太多,但在这种情况下,它必须的node.js

edit: Both applications run on the same machine. The c# application would provide 3 arguments to the node.js application. The node.js application would query a web service (POST), receive some XML data and manipulate that data. I know that i could do that task in c# too, but in this case it has to be node.js.

EDIT2和解决方案:现在,我已经选择: 4。你的节点的进程中运行的套接字服务器和C#应用程序确实通过TCP 要求

edit2 and solution: right now i have choosen: 4. Your node process runs a socket server and your C# app does requests over tcp.

我也将提供,似乎工作的解决方案:

I will also provide a solution that seems to work:

  • Node.js part: http://www.hacksparrow.com/tcp-socket-programming-in-node-js.html
  • C# part: http://www.codeproject.com/Articles/1415/Introduction-to-TCP-client-server-in-C

现在您就可以从你的C#应用​​程序发送任何数据到节点.js文件服务器。

Now you are ready to send any data from your c# application to the node.js server.

推荐答案

是通信是可能就像几个人在你的问题的评论所指出的那样。

Yes communication is possible like several people have pointed out in your question's comments.

以上是(部分)的选项:

These are (some of) the options:


  1. 您的节点的进程中运行一个HTTP服务器和你的C#应用over HTTP都JSON REST请求

  2. 您的节点进程运行使用节点肥皂SOAP Web服务模块

  3. C#应用程序启动您的节点应用程序,你做IPC通过写节点过程InputStream和读取它的输出流。

  4. 您节点进程运行的套接字服务器和C#应用程序通过TCP做的请求。

  5. 您使用Redis的一样或消息队列

  6. 第三名进程/服务器
  7. 凡是允许您共享文件一样的数据。

  1. Your node process runs an http server and your C# app does JSON Rest requests over http
  2. Your node process runs a SOAP webservice using the node-soap module
  3. C# app starts your node app and you do IPC by writing to the node process inputstream and read it's outputstream.
  4. Your node process runs a socket server and your C# app does requests over tcp.
  5. You use a 3rd process/server like Redis or a Message Queue
  6. Anything that allows you to share data like files..

我建议你去的第一选择,因为不需要您定义的语言协议在线送。另一个原因是,有很多做与C#和Node.js的休息可用文档。

I would recommend you go for the first option as that doesn't require you to define a language protocol to send over the "wire". The other reason would be that there is a lot of documentation available on doing Rest with C# and node.js.

由于C#中的客户端库,我建议你有一个看看 Restsharp 作为客户端库,如果你不能使用最新版本的.NET(4.5)。如果您可以使用最新版本,使用的 HttpClient的打电话给你的Node.js restservice。
为节点只使用快递。

As the client library in C# I would suggest you have a look at Restsharp as the client library if you can't use the latest version of .NET (4.5). If you can use the latest version, use HttpClient to call your Node.js restservice. For Node just use Express.

,因为在VS良好的支持Web服务选项2可能会很快,但是,我只用节点皂客户因此无法在节点皂Web服务如何与C#的客户发表评论。

Option 2 might be quick as there is good support in VS for webservices, however, I have only used node-soap as a client so can't comment on how well the node-soap webservices are with C# clients.

这篇关于我C#应用程序和Node.js的代码之间的沟通?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆