Protobuf-net wcf响应

时间:2014-01-30 11:29:27

标签: wcf protobuf-net

我正在尝试使用wcf使用protobuf-net序列化 我在客户端app.config和服务器web.config,装饰对象和服务接口上添加了必要的配置设置。 我正在使用fiddler来检查请求和响应。该请求正在使用proto序列化,但来自wcf服务的响应使用datacontractserializer。 我能够序列化和反序列化wcf服务之外的onjects。

关于我可能做错的任何建议? 提前致谢

@Marc Gravell - 你能帮忙解决这个问题吗?我以前能够毫无问题地配置Proto Serialization,但这次我遇到了问题。以下是app.config(相关部分)和web.config 的web.config

   <extensions>
        <behaviorExtensions>
        <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net" />
       </behaviorExtensions>
   </extensions>

    <behavior name="ProtoLargeDataEndpointBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <protobuf />
    </behavior>
    <behavior name="LargeDataEndpointBehavior">


     <service name="EOG.Modules.Cashflows.DataServices.CashflowAcrossStreamsService" behaviorConfiguration="DebugServiceBehavior">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="InsecureTcp" behaviorConfiguration="LargeDataEndpointBehavior" contract="EOG.Modules.Cashflows.Common.Interfaces.ICashflowAcrossStreamsService" />
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
    <endpoint address="proto" binding="netTcpBinding" bindingConfiguration="InsecureTcp" behaviorConfiguration="ProtoLargeDataEndpointBehavior" contract="EOG.Modules.Cashflows.Common.Interfaces.ICashflowAcrossStreamsService" />

    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttp" behaviorConfiguration="LargeDataEndpointBehavior" contract="EOG.Modules.Cashflows.Common.Interfaces.ICashflowAcrossStreamsService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="proto" binding="basicHttpBinding" bindingConfiguration="basicHttp" behaviorConfiguration="ProtoLargeDataEndpointBehavior" contract="EOG.Modules.Cashflows.Common.Interfaces.ICashflowAcrossStreamsService" />
  </service>


   App.config
   <endpointBehaviors>
    <behavior name="proto">
      <protobuf />
    </behavior>
    <behavior name="LargeDataEndpointBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
    <behavior name="ServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
    <behavior name="ProtoServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <protobuf />
    </behavior>
  </endpointBehaviors>

 <extensions>
  <behaviorExtensions>
    <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net" />
  </behaviorExtensions>
 </extensions>
   <endpoint address="http://server_name/iEconLiteServices/CashflowService.svc/proto" behaviorConfiguration="ProtoServiceBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttp" contract="EOG.Modules.Cashflows.Common.Interfaces.ICashflowAcrossStreamsService" />

以下是来自fiddler的截图,其中显示了在proto中序列化的请求以及使用Datacontractserializer的响应。

https://drive.google.com/file/d/0B1IidY-dzmRLYV9vdDNaTm4wNzg/edit?usp=sharing

任何见解都将受到赞赏。

1 个答案:

答案 0 :(得分:0)

问题原来是Contract方法返回的是一种对象而不是特定类型。