Adding protobuf-net to my WCF Rest service
===

Is there any canonical straight way of enabling protobuf-net serialization on .NET 4 WCF? I tried to simplify code to the point where it can be easy to build on:

Here is my service code:

    [ServiceContract]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class MobileServiceV2
    {
        [WebGet(UriTemplate = "/some-data")]
        [Description("returns test data")]
        public MyResponse GetSomeData()
        {
            return new MyResponse { SomeData = "Test string here" };
        }
    }
    
    [DataContract]
    public class MyResponse
    {
        [DataMember(Order = 1)] 
        public string SomeData { get; set; }
    }

I'm activating this service route in `Application_OnStart` (Global.asax) like so:

    RouteTable.Routes.Add(new ServiceRoute("mobile", new MyServiceHostFactory(), typeof(MobileServiceV2)));

I use `MyServiceHostFactory` to manage services with MEF, but that's irrelevant.

Configuration of my service is all default, the only additional stuff in Web.Config is here:

    <system.serviceModel>    
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <standardEndpoints>
          <webHttpEndpoint>
            <standardEndpoint helpEnabled="true" maxReceivedMessageSize="5242880" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            </standardEndpoint>
          </webHttpEndpoint>
        </standardEndpoints>
      </system.serviceModel>

Ok, service alive and running. There is mobile/help, I can issue GET on mobile/some-data and getting response in both XML and JSON

application/xml returns XML, application/json returns JSON

What do I need to do so clients can set application/x-protobufs and get their response encoded using protobuf-net?

I'm reading whole day and getting more and more confused... 

Here is what I found so far and nothing seems to give straight solution:

1. http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacontractserializer-serialization-in-wcf/

2. http://weblogs.thinktecture.com/cweyer/2010/12/using-jsonnet-as-a-default-serializer-in-wcf-httpwebrest-vnext.html

Second link is kind of what I need, but it doesnt work for me. Don't know why but I can't figure out which namespace `MediaTypeProcessor` lives in and just can't make it work in .NET4 ?

Various scattered info about configuring protobuf-net via web.config give me different errors and I'm just not sure I need to go that way. I'd rather have code-only solution.