VS2013无法在解决方案中添加WCF服务引用

问题描述 投票:0回答:2

我刚刚创建了一个 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) 不允许方法。 如果当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

当然,我用 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 错误。

enter image description here

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

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

wcf .net-3.5 visual-studio-2013 iis-express http-error
2个回答
0
投票

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

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

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


0
投票

我见过这个问题 ==> ListData.svc 是这里的关键 ==> 当为集合类使用不正确的数据契约属性时。

错误:

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

正确:

[CollectionDataContract]
public class MyClassList : List<MyClass>
{
}
© www.soinside.com 2019 - 2024. All rights reserved.