WCF服务不在同一服务器上通信

时间:2013-01-04 13:32:12

标签: c# asp.net wcf

WCF部署在IIS7上,通过网络访问AND网站(ASP.NET C#)也部署在同一台服务器上。通过网络WCF成功通信但在本地主机服务器上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>

AND网站配置如下

<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>

1 个答案:

答案 0 :(得分:0)

仅在localhostlocalhost:4570上投放。如果您使用端口4570,则需要在真实服务器上打开它。

如果您点击浏览器中的URL,WCF端点会返回什么,这通常可以解决问题。