views:

93

answers:

2

Hello guys.

I need fast transmit data from my wcf service to client. As SO helps, it means good binary serializer\derializer and data through List But I've got only XML text of DataTable serialized on service. It's big overhead.

Ok I should move to binary encoding of List. I haven't any DTO, just xml of DataTable. Could you help me with best practice

PS: At client I need datatable again for processing PSS: Http,Tcp bindings of wcf service.

+2  A: 

Indeed the first step in optimizing is getting rid of the DataTables and introducing model objects. Once this is done you could configure your service endpoint to use netTcpBinding for optimized binary transfer. Remember that this binding is not interoperable with non .NET clients so you could also have a basicHttpBinding endpoint exposed in case you need this.

At the end of the day there should be only model objects involved in the exposed service methods (no DataTables and DataSets):

[ServiceContract]
public interface IMyServiceContract
{
    [OperationContract]
    SomeModel[] GetModels();
}

This being said I would recommend you performing load tests and proving that this is a bottleneck for your application before trying to prematurely optimize it.

Darin Dimitrov
Nettcpbinding is very bloated in real terms. It's efficiency is generally vastly exaggerated.
Marc Gravell
Darin, thanks for the answer. But I've got a lot of legacy code, which uses datatable. I can't avoid them by introducing model objects.
Andrew Kalashnikov
+2  A: 

The first thing to try is to gzip the xml and aend via an mtom blob - simply a byte[] via wcf

If the XML is if a fixed schema, I would then consider writing some DTO translation code and send via protobuf-net and MTOM (reversing the translation at the other end).

I have an idea to pack adhoc datatables via protobuf-net but I haven't had chance to implement it yet which I discuss here: DataTable – life in the old beast?.

Marc Gravell
Marc thanks again!!! Your answer are perfect. I will try gzip with mton and track protobuf-net changes
Andrew Kalashnikov
http://marcgravell.blogspot.com/2010/10/datatable-life-in-old-beast.html :-)
Patrik
@Patrik - yes, that link looks oddly familiar. I already added it as a comment to the *question*, though.
Marc Gravell
Ah. Didn't see that :)
Patrik