WCF - “没有端点正在侦听......”错误

时间:2011-03-28 18:42:29

标签: wcf

我有两个应用程序,我想在同一台机器上本地测试。 App 1有一个简单的WCF服务,其中包含以下配置条目:

<service behaviorConfiguration="MyNamespace.ContainerManagementServiceBehavior"
        name="MyNamespace.ContainerManagementService">
  <endpoint address="ContainerManagementService" binding="basicHttpBinding"
     name="ContainerManagementbasicHttpEndpoint"
     contract="MyNamespace.IContainer" />
  <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  <host>
    <baseAddresses>
      <add baseAddress="http://localhost:8000/ContainerManagementService" />
    </baseAddresses>
  </host>
</service>    
<behaviors>      
  <behavior name="MyNamespace.ContainerManagementServiceBehavior">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="false" />
  </behavior>
</behaviors>

我通过运行托管它的Web应用程序项目来启动该服务。我能够成功浏览到url并从ie获取Web服务信息页面。我复制相同的URL并将其用于我的客户端。

我的其他客户端App 2在其配置文件中包含以下内容:

<system.serviceModel>
  <bindings>
    <basicHttpBinding>
      <binding name="basicHttp" closeTimeout="00:10:00"
        openTimeout="00:10:00" receiveTimeout="00:10:00"
        sendTimeout="00:10:00" allowCookies="false"
        bypassProxyOnLocal="false"
        hostNameComparisonMode="StrongWildcard"
        maxBufferSize="5242880" maxBufferPoolSize="524288"
        maxReceivedMessageSize="5242880" messageEncoding="Text"
        textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192"
          maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="5242880" />
        <security mode="None">
          <transport clientCredentialType="None"
            proxyCredentialType="None" realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <client>
    <endpoint
      address="http://localhost:3227/Services/ContainerManagementService.svc"
      binding="basicHttpBinding" bindingConfiguration="basicHttp"
      contract="MyService.IService" name="externalService" />      
  </client>
</system.serviceModel>

但是,当我尝试将WCF调用表单客户端执行到正在运行的服务时,我收到以下错误消息:

There was no endpoint listening at
http://localhost:3227/Services/ContainerManagementService.svc
that could accept the message. This is often caused by an incorrect
address or SOAP action. See InnerException, if present, for more details.

可能会发生什么?

3 个答案:

答案 0 :(得分:4)

看起来好像问题是由于服务器和客户端都是从Cassini服务器运行的。我正在更改体系结构以在IIS中托管服务器端点。

答案 1 :(得分:3)

你有两个申请吗?

一个托管服务器端点而另一个托管客户端?在IIS中都是活动的(考虑到第二个应用程序是一个Web应用程序)?

如果解决方案中有两个项目用于这两个组件,则可以配置VS以同时启动两个项目。这样,您可以在客户端和服务器上放置断点,并查看服务器是否真的被客户端调用,或者是否在没有调用服务器方法的情况下发生异常。

答案 2 :(得分:1)

如果您的网络服务已启用:http://localhost:8000/ContainerManagementService.svc

您的客户端app2应该指向同一个地址:

<client>
      <endpoint address="http://localhost:8000/ContainerManagementService.svc"
        binding="basicHttpBinding" bindingConfiguration="basicHttp"
        contract="MyService.IService" name="externalService" />      
</client>