连接到WCF服务时出现问题

时间:2015-01-27 11:47:03

标签: c# asp.net .net web-services wcf

我正在学习WCF并在托管后访问该服务时遇到一些问题。我创建了一个WCF服务,它在Web.config中有以下条目 -

服务Web.config

<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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 information -->
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<bindings>
  <basicHttpBinding>
    <binding maxReceivedMessageSize="2147483647"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647">
      <readerQuotas maxDepth="32"
                    maxArrayLength="2147483647"
                    maxStringContentLength="2147483647"/>
    </binding>
  </basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

现在,由于我想托管此服务,我按照this教程创建了一个负责托管此服务的控制台应用程序。这是主机的App.config -

主机App.config

<system.serviceModel>    
<services>
  <service name="ServiceName"
           behaviorConfiguration="ServiceNameBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:59918/ServiceName.svc"/>
      </baseAddresses>
    </host>
    <endpoint address=""
              binding="wsHttpBinding"
              contract="ServiceName.IServiceName" />
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceNameBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我运行主机并安装了服务。我现在可以从services.msc启动/停止服务,并且还能够正确地将引用添加到客户端。问题是,当我调用任何服务方法时,客户端无法连接到它并且只是超时。为什么会这样? Web.config和App.config在这里是否正确?

注意:我还处理大量数据传入和传出服务。这就是我设置maxRecievedMessageSize参数的原因。

0 个答案:

没有答案