WCF 配置

Posted MR_CHW

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WCF 配置相关的知识,希望对你有一定的参考价值。

主要是针对报错:This could be due to the service endpoint binding not using the HTTP protocol.......

(这是网上找的帖子,做个笔记便于查找,没有测试)

Client Config:

<?xml version="1.0"?>
<configuration>  
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_INextGenService" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                        <message clientCredentialType="UserName" algorithmSuite="Default"/>
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://gcotdvm3722126/CAT.NextGenService/NextGenService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_INextGenService" 

                      behaviorConfiguration="endpointBehavior" contract="INextGenService" name="BasicHttpBinding_INextGenService"/>
        </client>
      <behaviors>
        <endpointBehaviors>
          <behavior name="endpointBehavior">
            <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          </behavior>
        </endpointBehaviors>
      </behaviors>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Server Config:

<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="CATDbEnv" value="CATDB_CLOUD2"/>
  </appSettings>
  <connectionStrings>
    <add name="LEGACYCATDB_CLOUD2" connectionString="user id=legacycat;password=legacycat;data source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = vm-738e-a017.nam.nsroot.net)(PORT = 1522)))(CONNECT_DATA = (SID = CAT)))" providerName="System.Data.OracleClient"/>
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <httpRuntime maxRequestLength ="262144" executionTimeout="103600"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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 informaton -->
    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

 

以上是关于WCF 配置的主要内容,如果未能解决你的问题,请参考以下文章

WCF配置问题(配置WCF跨域)

将应用程序配置嵌入到 wcf 中的 c# 代码中

在 IIS 中托管时如何从代码配置 WCF 服务?

使用代码而不是配置文件将消息检查器添加到 WCF 服务

通过C#代码调用WCF服务中的一个方法。不依赖配置文件等。求完整代码!!

如何在代码而不是配置中创建 WCF EndPointBehaviors?