1

protobuf-net を使用するようにサービスを構成しようとしています。T[] と T を返すメソッドは機能しますが、List は null を返します。サポートされていますか?

また、シリアライゼーション中に実際にprotobufを使用していることをどのように確認できますか。フィドラーを使用しようとしましたが、違いがわかりません。

public interface IOrdersService
{        
    [OperationContract(IsOneWay = false)]
    OrderDTO[] GetAllOrders();

    [OperationContract(IsOneWay = false)]
    List<OrderDTO> GetAllOrders2();

    [OperationContract(IsOneWay = false)]
    OrderDTO GetOrder();
}

public class OrdersClient : IOrdersServiceCallback
{
    private OrdersServiceClient client;

    public OrdersClient()
    {

    }

    public void Init()
    {
        InstanceContext site = new InstanceContext(null, new OrdersClient());
        client = new OrdersServiceClient(site);
    }

    public void Start()
    {
        OrderDTO[] orders = client.GetAllOrders();

        OrderDTO[] orders2 = client.GetAllOrders2();

        OrderDTO dto = client.GetOrder();
        Console.WriteLine(dto);
    }        
}

ウェブ構成

<?xml version="1.0"?>
<configuration>

<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
  <services>
    <service name="OrdersServer.OrdersService">
      <endpoint address=""
                binding="wsDualHttpBinding" 
                bindingConfiguration="Binding1"
                contract="OrdersServer.IOrdersService"                  
                behaviorConfiguration="ProtoBufBehavior" />
    </service>
  </services>
  <bindings>
    <wsDualHttpBinding>
      <binding name="Binding1">
        <!-- Binding property values can be modified here. -->
        <security mode="None"/>
      </binding>
    </wsDualHttpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior>
        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
        <serviceDebug includeExceptionDetailInFaults="false"/>
      </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
      <behavior name="ProtoBufBehavior">
        <protobuf />
      </behavior>
    </endpointBehaviors>
  </behaviors>
  <protocolMapping>
      <!--add binding="basicHttpsBinding" scheme="https" />-->
      <add scheme="http" binding="wsDualHttpBinding"/>
  </protocolMapping>    
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  <extensions>
    <behaviorExtensions>
      <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.640, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"/>
    </behaviorExtensions>
  </extensions>
</system.serviceModel>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
  <!--
      To browse web app root directory during debugging, set the value below to true.
      Set to false before deployment to avoid disclosing web app folder information.
    -->
  <directoryBrowse enabled="true"/>
</system.webServer>

</configuration>

クライアント構成

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="WSDualHttpBinding_IOrdersService" clientBaseAddress="http://localhost:8000/whatisthis/">
                    <security mode="None" />
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost.fiddler:49522/OrdersService.svc"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IOrdersService"
            contract="OrdersServiceReference.IOrdersService" name="WSDualHttpBinding_IOrdersService"
                   behaviorConfiguration="proto"/>
        </client>
        <behaviors>
          <endpointBehaviors>
            <behavior name="proto">
              <protobuf />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <extensions>
          <behaviorExtensions>
            <add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.640, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"/>
          </behaviorExtensions>
        </extensions>
    </system.serviceModel>
</configuration>
4

0 に答える 0