如何在客户端和服务器上将服务参数设置为相同?

时间:2012-12-06 10:06:18

标签: wcf .net-3.5

我在服务器上的客户端和WCF服务之间存在版本不匹配。

如何在客户端和服务器上将服务参数设置为相同?我知道我应该设置消息版本,地址和编码,但我应该在web.config文件或代码中设置它们的确切位置?

以下是我的web.config文件:

1)服务:

<system.serviceModel>
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <add prefix="http://localhost:80/"/>
    </baseAddressPrefixFilters>
  </serviceHostingEnvironment>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Parus.ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost/AsurReceiveData/Service.svc"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
        <MyInspector />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="Parus.ServiceBehavior" name="Parus.Service">
      <endpoint address="http://localhost/AsurReceiveData/Service.svc" binding="basicHttpBinding" contract="Parus.IService">
      </endpoint>
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
    </service>
  </services>
  <extensions>
    <behaviorExtensions>
      <add name="MyInspector" type="Parus.MessageInspectorExtension, Parus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    </behaviorExtensions>
  </extensions>
</system.serviceModel>

2)客户:

<system.serviceModel>
<bindings>
 <basicHttpBinding>
  <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
   openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
   allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
   maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
   messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
   useDefaultWebProxy="true">
   <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
   <security mode="None">
    <transport clientCredentialType="None" proxyCredentialType="None"
     realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
   </security>
  </binding>
 </basicHttpBinding>
</bindings>
<client>
 <endpoint address="http://localhost/AsurReceiveData/Service.svc"
  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
  contract="ServiceReference.IService" name="BasicHttpBinding_IService" />
</client>
</system.serviceModel>

0 个答案:

没有答案
相关问题