WCF的配置Web.config及发布需要注意的问题

在开发环境下可以正常调用,但到发布后,为何不可以调用?

 

一、WCF的配置文件web.config,主要配置:behaviors、bindings、services

  <system.serviceModel>
    <diagnostics>
      <messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
        logMessagesAtTransportLevel="true" />
    </diagnostics>

    <behaviors>
      <serviceBehaviors>
        <behavior name="NewBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="65536000" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <wsHttpBinding>
        <binding name="NewBindingStationCnfg" maxReceivedMessageSize="655360000" />
      </wsHttpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="NewBehavior" name="GlacierICR.SRV.BaseSearchSRV">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/GlacierICR.SRV/"/>
          </baseAddresses>
        </host>
        <endpoint  binding="wsHttpBinding" bindingConfiguration="NewBindingStationCnfg" contract="GlacierICR.ISRV.IBaseSearchSRV" />
      </service>

    </services>
  </system.serviceModel>


二、WebClient的Web.Config

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IBaseSearchSRV" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="655360000"
          messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
          allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost/GlacierICR.SRV/BaseSearchSRV.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBaseSearchSRV"
        contract="BaseSearchRef.IBaseSearchSRV" name="WSHttpBinding_IBaseSearchSRV">
        <identity>
          <servicePrincipalName value="host/localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>


如果只有上面两步,开发环境调试没问题,但发布后可能有问题,所以还要有第三步:

三、在WebClient下面要加两个文件

1. clientaccesspolicy.xml

<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from>
                <domain uri="*"/>
            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>


 

2. crossdomain.xml

<?xml version="1.0" encoding="utf-8" ?>
<cross-domain-policy>
    <allow-access-from domain="*" />
</cross-domain-policy>


 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值