简体   繁体   English

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

[英]WCF - “There was no endpoint listening at…” error

I have two applications that I want to test locally on the same machine. 我有两个应用程序,我想在同一台机器上本地测试。 App 1 has a simple WCF service with the folloiwng config entry: App 1有一个简单的WCF服务,带有folloiwng配置条目:

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

I start the service by running the web application project where it is hosted. 我通过运行托管它的Web应用程序项目来启动该服务。 I am able to successfully browse to the url and get web service information page from ie. 我能够成功浏览到url并从ie获取Web服务信息页面。 I copy the same URL and use it for my client. 我复制相同的URL并将其用于我的客户端。

My other client, App 2, has the following in its config file: 我的其他客户端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>

However, when I try to execute a WCF call form client to the running service, I get the following error message: 但是,当我尝试执行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.

What could be happening? 可能会发生什么?

It looks likes the issue is due to the fact that both server and client are being run from the Cassini server. 看起来好像问题是由于服务器和客户端都是从Cassini服务器运行的。 I am changing the architecture to host the server endpoint in IIS. 我正在更改体系结构以在IIS中托管服务器端点。

Do you have two applications ? 你有两个申请吗?

One which hosts the server endpoint and the other which is the client ? 一个托管服务器端点而另一个托管客户端? Are both active in IIS (considering the second application is a web app) ? 在IIS中都是活动的(考虑到第二个应用程序是一个Web应用程序)?

If you have two projects for those two components in your solution, you can configure VS to start both project at the same time. 如果解决方案中有两个项目用于这两个组件,则可以配置VS以同时启动两个项目。 This way you can put breakpoints on both the client and the server and see if the server really gets called by the client or if the exception happens without the server method being called. 这样,您可以在客户端和服务器上放置断点,并查看服务器是否真的被客户端调用,或者是否在没有调用服务器方法的情况下发生异常。

If your web service is on: http://localhost:8000/ContainerManagementService.svc 如果您的Web服务已启用: http:// localhost:8000 / ContainerManagementService.svc

Your client app2 should point on this same addres: 您的客户端app2应该指向同一个地址:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM