C# 带有协议缓冲区的WCF服务,配置文件的外观
我以前在WCF工作过。但我对协议缓冲区很陌生。我讲述了它的优点以及如何使用它。基本上,我想将协议缓冲区插入我现有的“WCF库”。那么,为了引入或开始使用协议缓冲区,我应该在现有的“app.config”文件中进行哪些更改? 我现有的服务配置文件如下所示C# 带有协议缓冲区的WCF服务,配置文件的外观,c#,protocols,protocol-buffers,app-config,servicecontract,C#,Protocols,Protocol Buffers,App Config,Servicecontract,我以前在WCF工作过。但我对协议缓冲区很陌生。我讲述了它的优点以及如何使用它。基本上,我想将协议缓冲区插入我现有的“WCF库”。那么,为了引入或开始使用协议缓冲区,我应该在现有的“app.config”文件中进行哪些更改? 我现有的服务配置文件如下所示 <configuration> <appSettings> <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&g
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="XYZProvider">
<providers>
<add name="XYZshipProvider" type="System.Web.ClientServices.Providers.XYZProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf35678563123ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856564ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="wcfServiceXYZApplication.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/XYZApplication/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="XYZApplication.IService1" bindingConfiguration="basicHttp">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<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>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" maxReceivedMessageSize="100000" maxBufferSize="100000" maxBufferPoolSize="100000"/>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
请帮忙!
谢谢以下是我在服务端的配置中所做的修改
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="XYZProvider">
<providers>
<add name="XYZshipProvider" type="System.Web.ClientServices.Providers.XYZProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf35678563123ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856564ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="protoEndpointBehavior">
<protobuf/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netNamedPipeBinding>
<binding name="namedPipeBinding" receiveTimeout="00:10:00" sendTimeout="0:10:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</netNamedPipeBinding>
</bindings>
<services>
<service name="WcfProtobufService.SimpleService">
<endpoint binding="netNamedPipeBinding" bindingConfiguration="namedPipeBinding" contract="WcfProtobufService.ISimpleService" behaviorConfiguration="protoEndpointBehavior"/>
<endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/console/SimpleService.svc"/>
</baseAddresses>
</host>
</service>
</services>
<extensions>
<behaviorExtensions>
<add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.668, Culture=neutral, PublicKeyToken=257b51d87d2e4d67"/>
</behaviorExtensions>
</extensions>
服务更改-只需在服务契约上添加Protocontract属性
[协议][服务合同] 最后但并非最不重要的是添加
using ProtoBuf
参考
请在您的答案中输入足够的信息,这样即使链接消失,您的答案仍然有用。目前这是一个链接唯一的答案,这是一个候选人删除。谢谢通知我。。。我将分享我实现的实际解决方案。这会更好。感谢您花时间将信息输入到答案中。谢谢。。。我不知道如何处理“禁止提问”的问题?无法从该帐户询问任何问题。我用更多的解释编辑了所有的问题,删除了重复的问题。。还是一样的问题。您能给我一些建议吗?作为上述解决方案的补充,如果您不想通过客户端和服务器端的App/Web.config文件进行配置,请使用ProtoBuf.ServiceModel添加
代码>并向服务接口函数添加[ProtoBehavior]
[ProtoMember(2)]
[DataMember(Order = 0)]
public string Name { get; set; }
using ProtoBuf