Protocol buffers over HTTP GET using WCF

I have a WCF service that returns protobuf-net serial data bytes []. Initially, this was placed on top of the default webHttpBinding (SOAP) settings, and everything worked correctly. I recently found out that I need to call HTTP GET and POST directly from our client, so I thought it would be easier to switch to using the RESTful service. I switched to using the WebGet attribute and the WCF REST template.

I tried to create a simple website for testing the client, and I had problems with data deserialization. This is an example of how I call the service:

using (WebClient client = new WebClient())
{
    result = client.DownloadString(url);
}    
// Deserialize 
BinaryVehicles binVehs;
using (var ms = new MemoryStream(StrToByteArray(result)))
{
    binVehs = Serializer.Deserialize<BinaryVehicles>(ms);
}

An example of what is returned in the "result": <base64Binary xmlns = "http://schemas.microsoft.com/2003/10/Serialization/"> ChsKCzEyMy00NTYnNzg5EgU0NDAwMBoFQmxhY2sKHAoLOTYzLTg1Mi03NDESBTIzMDAwGZZ = / 2BZZBZZ Base2

I also tried to deserialize the data between <base64Binary> with no results. Does anyone have an idea how I should send protobuf-net binary data from the WebGet method and how should I deserialize the data? Thank.

+3
source share
1 answer

protobuf-net primarily handles only serialization aspects (the Google protobuf specification does not define this further). So it really comes down to: how do you serialize it?

, WCF GET - , , . , base-64 , , , HTTP GET, WCF .

I ASP.NET MVC protobuf HTTP GET. ASP.NET.

- , , WCF GET , ...

+2

Source: https://habr.com/ru/post/1753455/