没有端点监听本地的“…”

本文关键字:端点 监听 | 更新日期: 2023-09-27 18:16:42

我已经得到了一个wcf服务,并且我构建了一个本地控制台应用程序来测试它,但我一直得到标题中显示的这个错误。我的服务应该在浏览器中运行,显示显示示例的屏幕和您可以测试它的url。可能是网络出了问题。配置或在App.config. conf文件中。我有这两个文件:

Web.condig

<?xml version="1.0"?>
<configuration>
  <appSettings>
  ...
  </appSettings>
  <system.web>
    <compilation debug="false" targetFramework="4.0"/>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"/>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webHttpBehavior">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <services>
      <service name="RAHPEDWCFService.RAHPEDService">
        <endpoint address="http://localhost:44184/RAHPEDService.svc" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="RAHPEDWCFService.IRAHPEDService"/>
      </service>
    </services>
  </system.serviceModel>
</configuration>

App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IRAHPEDService" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false"
        hostNameComparisonMode="StrongWildcard"
        maxBufferSize="65536" maxBufferPoolSize="524288"
        maxReceivedMessageSize="65536"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192"
          maxArrayLength="16384" maxBytesPerRead="4096"
          maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
            realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:44184/RAHPEDService.svc"
      binding="basicHttpBinding"
      bindingConfiguration="BasicHttpBinding_IRAHPEDService"
      contract="ServiceReference.IRAHPEDService"
      name="BasicHttpBinding_IRAHPEDService" />
    </client>
  </system.serviceModel>
</configuration>

我希望有人能给我一个提示。

没有端点监听本地的“…”

请按照以下步骤解决

  1. 请浏览您的服务,并点击Url是否显示元数据。例:http://橙汁:23/Myservice吗?wsdl
  2. 如果没有启用元数据,那么对您的服务配置文件进行以下更改。1 .创建一个mex端点2命名服务行为例:& lt;serviceBehaviors>& lt;行为的名字= " SerBehavior ">& lt;serviceMetadata httpGetEnabled = " true "/>& lt;/行为>& lt;/serviceBehaviors>3将此行为添加到您的服务中例:& lt;服务名称= " RAHPEDWCFService。RAHPEDService" behaviorConfiguration="SerBehavior"> iv.构建服务并点击url查看元数据
  3. 在控制台应用程序中右键单击项目并单击Add Service Reference
  4. 将Url放在地址框中,单击Go检查是否可以看到服务,选择服务并给出命名空间,然后单击OK
  5. 创建ServiceClient
  6. 的对象
  7. 调用方法

能够在浏览器中看到WSDL元数据。
如果您的客户端配置文件中有多个端点,那么您必须将端点的名称传递给ServiceCleint类的构造函数

打开Visual studio CommandPrompt,输入WcfTestClient,右键单击MyServiceProjects,添加服务并检查是否可以添加,一旦添加,调用端点下的方法出现

您应该检查您正在访问正确的地址。而不是在Web中指定整个地址。配置时,更常见的做法是只提供一个相对地址(甚至一个空的"就可以了),然后使用:

访问服务
http://servername:[port]/[virtual directory]/RAHPEDWCF.svc/[relative address in Web.config]

。如果地址在Web。Config show

endpoint address="MySVC" 

客户端的完整URL(假设默认端口80并且位于虚拟服务器的根目录)可能是

http://servername/RAHPEDWCF.svc/MySVC

如果您可以修改Web。