简体   繁体   English

Java android 客户端与 C# 服务器通信

[英]Java android client communication with C# server

I am currently writing an application having a client server architecture.我目前正在编写一个具有客户端服务器架构的应用程序。

The client is a Java android application The server is a C# application.客户端是 Java android 应用服务器是 C# 应用。

The client will pull data from the server but in some cases push some data to the C# server as well.客户端将从服务器拉取数据,但在某些情况下也会将一些数据推送到 C# 服务器。

The data that server needs to forward the clients is list of data structures (perhaps in the form of XML?), sometime binary data like files.服务器需要转发客户端的数据是数据结构列表(可能是 XML 的形式?),有时是二进制数据,如文件。

The client and server are communicating over a wireless.network.客户端和服务器通过无线网络进行通信。

Speed and scalability is my top most priority in the design of the system,...速度和可扩展性是我在系统设计中的首要任务,...

I have to write server as well as the client myself.我必须自己编写服务器和客户端。 I will be using sockets for communication.我将使用 sockets 进行通信。

I need your advise on the form of protocol I should use to exchange data between the Java client and C# server.我需要您建议我应该使用哪种协议在 Java 客户端和 C# 服务器之间交换数据。

Should I write similar data structures (which seems redundant) in java and C# and serialize them??我应该在 java 和 C# 中编写类似的数据结构(这似乎是多余的)并序列化它们吗?

or should I exchange xml??或者我应该交换 xml?

I am not sure yet what is the best way to do it.. Essentially there will be commands from client and server will respond with data我还不确定最好的方法是什么。基本上会有来自客户端的命令,服务器将响应数据

Please advise me on this topic the data communicated could be be as large as several gigs over wifi so speed is very important.请就此主题向我提供建议,通过 wifi 传输的数据可能高达几千兆,因此速度非常重要。

I believe WCF might be approperiate for this, WCF uses soap so a Java implementation should work well.我相信WCF可能适用于此, WCF使用 soap,因此 Java 实现应该运行良好。 WCF also supports steaming, so transferring large files is possible, though I'm not sure if Java supports the streaming protocol. WCF也支持流媒体,所以可以传输大文件,不过我不确定Java是否支持流媒体协议。

As for performance, you will probably be limited by the speed of the device and not the protocol.至于性能,您可能会受到设备速度而非协议的限制。

Have a look at this session from TechEd 2011: "My Customers Are Using iPhone/Android,But I'm a Microsoft Guy. Now What?"看看来自 TechEd 2011 的 session:“我的客户正在使用 iPhone/Android,但我是 Microsoft Guy。现在怎么办?”

http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR304 http://channel9.msdn.com/Events/TechEd/NorthAmerica/2011/DPR304

It would probably be worth looking into MonoDroid if you want to share code between client and server (and if serialize/de-serialize makes sense).如果您想在客户端和服务器之间共享代码(如果序列化/反序列化有意义),可能值得研究一下MonoDroid

As I don't know what you're building, I would advise you to read up on REST before you continue though.由于我不知道你在建造什么,我建议你在继续之前阅读 REST。 It should give you valuable pointers on how to create a nice API that can be easily consumed by various clients.它应该为您提供宝贵的指导,说明如何创建一个可以被各种客户轻松使用的漂亮的 API。

Well, there's always JSON. It should be well-supported on both ends and is easy for your server to generate and client to consume.好吧,总是有 JSON。它应该在两端得到很好的支持,并且很容易让您的服务器生成和客户端使用。 Not sure it helps with your bandwidth concerns any...不确定它是否有助于解决您的带宽问题...

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

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