Mattia Durli
Mattia Durli

Reputation: 767

WCF with Android (TCPBinding) and ServiceStack

I'm investigation different options to access remote data for an Android application(in the future WindowsEmbedded and possibly iOS with monotouch), so I've made some tests and I'm trying to understand what is possible and is not possible to do.

I already have a client(WindowsCE)/server(win32) solution that uses raw sockets. I'll rewrite the server with .NET,and for communication I would like to try WCF. I wrote a simple WCF .NET server application, and connected to it with basicHTTPBinding with Android, and it works. But for performance reasons I want to use TCPBinding, and I got stuck with svcutil etc etc, and I can't understand if I'm unable to do it or if is not possible. Is WCF fully, partially, going to be fully supported in mono for android?

If the answer is no, and I cannot use binary TCP binding with WCF, what would it be the advantage of moving to ServiceStack (havent't tested yet, but seems to be considered better than WCF).

Thanks!

Upvotes: 3

Views: 1254

Answers (1)

mythz
mythz

Reputation: 143379

I personally wouldn't try to use WCF on embedded devices, especially on Mono where it only has partial support of the WCF Stack. Also the default binary serializer used in WCF tcp binding is actually both slow and requires a larger payload than most serializers:

ProtoBuf

  • Size (bytes): 133,010
  • Serialize (ms): 10,769
  • DeSerialize (ms): 23,511

NetDataContractSerializer (WCF Binary)

  • Size (bytes): 992,203
  • Serialize (ms): 29,343
  • DeSerialize (ms): 91,453

Currently for the best performance in ServiceStack you can enable .NET's fastest binary formats via NuGet plugins, see:

The nice thing about using ServiceStack is because all the typed C# Clients share the same interfaces you can easily develop with a flexible and debugger friendly format like JSON (which is also fast) and then when you're done development, easily switch over to one of the binary formats above for maximum performance.

Future TCP Endpoint support planned for ServiceStack

Because ServiceStack's Architecture makes it easy to support multiple endpoints, we also plan on enabling a fast TCP Endpoint after we've merged our async branch. It will work transparently like our other ServiceClients so will be just as easy to switch to by using another ServiceClient.

Upvotes: 3

Related Questions