【问题标题】:VS2013 cannot add WCF service reference in solutionVS2013无法在解决方案中添加WCF服务引用
【发布时间】:2014-08-24 22:09:14
【问题描述】:

我刚刚创建了一个 WCF 网站 .net 3.5,我认为通过创建一个默认站点就足以复制。但它很难复制。我有 VS2013 以及从我的 MSDN 下载的所有更新,并且我有 Windows 8.1。

我必须说,几个月前我在一些机器上遇到了这个问题,所以其他机器帮忙,我假设它与安装有关,但现在它出现在 3 台不同的机器上,其中一台它们使用 Windows 8。它们都是 64 位的。

服务做得很完美,因为到目前为止我的交付和生产都是如此,它运行顺利。

现在我创建了一个基本的 ASP.net aqlso .net 3.5。并尝试添加服务引用,但添加失败后显示以下消息。

下载时出错 'http://localhost:40226/HabeasDataService.svc/_vti_bin/ListData.svc/$metadata'。 请求失败,HTTP 状态为 404:未找到。 元数据包含无法解析的引用:“http://localhost:40226/HabeasDataService.svc”。吨 远程服务器返回意外响应:(405) 方法不允许。 远程服务器返回错误:(405) Method Not Allowed。 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

当然,我使用 clena 进行了重建,但问题仍然存在。

服务的配置如下

<system.serviceModel>
<services>
  <service behaviorConfiguration="ServicesLayer.Service1Behavior"
    name="ServicesLayer.Service1">
    <endpoint 
      bindingConfiguration="BigHttpBinding"
      name="BasicHttp"
      address="" 
      binding="basicHttpBinding" 
      contract="ServicesLayer.IHabeasDataService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServicesLayer.Service1Behavior">
      <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
      <serviceMetadata httpGetEnabled="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="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding
      name="BigHttpBinding"
      maxBufferSize="65536"
      maxBufferPoolSize="65536"
      maxReceivedMessageSize="65536"
      transferMode="Buffered">
      <readerQuotas
        maxDepth="64"
        maxStringContentLength="65536"
        maxArrayLength="65536"
        maxBytesPerRead="4096"
        maxNameTableCharCount="32768"/>
    </binding>
  </basicHttpBinding>
</bindings>
</system.serviceModel>

我注意到这一行:

<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
      <serviceMetadata httpGetEnabled="true"/>

并尝试两种配置,仍然是同样的错误。

当我尝试通过单击浏览器中的视图来运行 svc 文件时,我收到了一个类似这样的 404.17 错误。

这非常令人沮丧,因为它完全阻碍了开发。

注意 与 IIS 相关的所有内容都可能有用,但请记住它是 IIS Express。无论如何切换到本地 IIS,仍然失败,但正如我所说。在生产服务器上它是薄荷的

【问题讨论】:

  • 404.17 它可能指向安装错误。检查此stackoverflow.com/questions/87107/… 以及该站点在哪个框架版本上运行
  • 该站点位于 .net 3.5 上。您提供的解决方案是针对 IIS 的。我还在开发时间,我正在使用 VS2013,并且使用 IIS Express 进行调试。在那里我找到了一个链接,我会检查一下
  • 您是从bindebug 文件夹中添加一些引用dll 吗?还是在任何地方都使用 Windows 身份验证/模拟?
  • 不,我只是通过菜单选项做了标准程序,添加服务参考,发现,双击显示方法和BOOM我在问题中发布的错误出现
  • 您找到解决方案了吗?我有一个相同的问题

标签: wcf .net-3.5 visual-studio-2013 iis-express http-error


【解决方案1】:

根据错误,可能是在 WCF 之后安装了 IIS。

我遇到了类似的问题,下面的链接帮助我解决了它

http://msdn.microsoft.com/en-gb/library/vstudio/ms752252(v=vs.90).aspx

【讨论】:

  • 但是,正如我所说,它与 IIS 无关,因为它发生在编程时间,当我要求 Visual Studio 添加对项目的服务引用时,它会引发此错误。我在IIS里处理过,很容易解决,但是用IS EXPRESS,就是一场噩梦
【解决方案2】:

我已经看到了这个问题 ==> ListData.svc 是这里的关键 ==> 当为集合类使用不正确的数据协定属性时。

不正确:

[DataContract]
public class MyClassList : List<MyClass>
{
}

正确:

[CollectionDataContract]
public class MyClassList : List<MyClass>
{
}

【讨论】:

  • 奇怪的是,在运行相同解决方案的其他 PC 中不会引发同样的错误。我开始认为这不是与解决方案相关的问题,而可能是硬件-软件配置问题。可悲的是,我不再有这个问题的 PC,所以现在无法测试任何东西。但我确实在合作伙伴的计算机上测试过运行相同的解决方案,并且很顺利
  • 听起来这个错误可能有多种原因。但我只是想添加我对这个错误的发现 - 因为其他人可能遇到与我相同的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-12
  • 2014-02-13
  • 1970-01-01
  • 2016-11-21
  • 2011-04-12
  • 2014-05-08
  • 1970-01-01
相关资源
最近更新 更多