1

WCF 部署在 IIS7 上,通过网络访问和网站(ASP.NET C#)也部署在同一台服务器上。通过网络 WCF 通信成功,但在 localhost 服务器上 WCF 不与网站通信。我对 wcf 的配置是

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IWITSService" closeTimeout="00:00:05"
                  openTimeout="00:00:05" receiveTimeout="00:10:00" sendTimeout="00:00:05"
                  bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
                  textEncoding="utf-8" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <!--<reliableSession ordered="true" inactivityTimeout="00:10:00" />-->
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None" />


                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4570/WITSWCFService.svc"
              binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWITSService"
              contract="WITS.IWITSService" name="BasicHttpBinding_IWITSService" >
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

和网站配置如下

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding  name="BasicHttpBinding_IWITSService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferPoolSize="524288">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" 
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"  />
        </binding>
      </basicHttpBinding>
      <!--<webHttpBinding>
        <binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </webHttpBinding>-->
    </bindings>
    <services>
      <service name="WITSService.WITSService">
        <clear />
        <endpoint binding="basicHttpBinding" contract="WITSService.WITSService"   />
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false"/>

        </behavior>
      </serviceBehaviors>

    </behaviors>


  </system.serviceModel>
4

1 回答 1

0

localhost仅在 或上运行localhost:4570。如果您使用端口4570,则需要在真实服务器上打开它。

如果您在浏览器中点击 URL,WCF 端点会返回什么,这通常很能说明问题。

于 2013-01-04T13:35:56.747 回答