没有端点在本地" ..."

时间:2014-08-04 17:19:38

标签: c# wcf service

我已经获得了一个wcf服务,我构建了一个本地控制台应用程序来测试它,但我不断收到标题中显示的错误。我的服务在浏览器中运行,它显示了显示示例的屏幕以及可以测试它的URL。可能是错误发生在Web.config或App.config中。我有这两个文件:

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>

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

2 个答案:

答案 0 :(得分:0)

您应该检查您是否正在访问正确的地址。而不是在Web.config中指定整个地址,更常见的做法是仅提供相对地址(甚至 一个空的&#34;&#34;很好),然后你用:

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

E.g。如果Web.config中的地址显示

endpoint address="MySVC" 

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

http://servername/RAHPEDWCF.svc/MySVC

如果您能够修改Web.config,我建议这样做。

答案 1 :(得分:0)

请按照以下步骤解决此问题

  1. 请浏览您的服务,然后点击Url是否显示元数据。 例如:http:// oj:23 / Myservice?wsdl
  2. 如果未启用元数据,请对服务配置文件执行以下更改。 一世。创建一个mex端点 II。命名服务行为 例如: &LT; serviceBehaviors&GT; &LT; behavior name =“SerBehavior”&gt; &LT; serviceMetadata httpGetEnabled =“true”/&gt; &LT; /行为&GT; &LT; / serviceBehaviors&GT; III。将此行为添加到您的服务   例如: &LT; service name =“RAHPEDWCFService.RAHPEDService”behaviorConfiguration =“SerBehavior”&gt; &LT; /服务&GT; IV。构建服务并浏览单击url以检查metaData
  3. 在控制台应用程序中右键单击项目,然后单击“添加服务参考”
  4. 将Url放入地址框,点击Go检查您是否能够看到该服务,选择您的服务并命名空间并单击确定
  5. 创建ServiceClient的对象
  6. 致电您的方法
  7. 能够在浏览器中看到wsdl元数据 如果您的客户端配置文件中有多个端点,那么您已将端点的名称传递给ServiceCleint类的构造函数

    打开Visual Studio CommandPrompt并输入WcfTestClient,右键单击MyServiceProjects,添加服务并检查是否能够添加,并且一旦添加调用,您的方法就会出现在端点下