【问题标题】:WCF bindings mismatchWCF 绑定不匹配
【发布时间】:2014-03-13 20:26:46
【问题描述】:

我是 WCF 的新手,我遇到了问题。我有一个带有 WCF 服务和单元测试的解决方案。我可以构建解决方案,但是当我转到 -> 添加服务参考 -> 发现并单击我的服务时,我得到了这个异常

下载'http://localhost/MyService.svc/_vti_bin/ListData.svc/$metadata' 时出错。 请求失败,HTTP 状态为 404:未找到。 元数据包含无法解析的引用:'http://localhost/MyService.svc'。 内容类型应用程序/soap+xml;服务 http://localhost/MyService.svc 不支持 charset=utf-8。客户端和服务绑定可能不匹配。 远程服务器返回错误:(415)不支持的媒体类型。 如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

我已经阅读了很多东西,但没有任何效果,有什么想法吗?

这是我的配置

 <?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="Services.Biceps.BicepsItemService.ServiceBehavior" name="BicepsItemService">
        <endpoint address="basic" binding="basicHttpBinding" contract="Services.Biceps.IItemService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
     <behaviors>
      <serviceBehaviors>
        <behavior name="Services.Biceps.BicepsItemService.ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

【问题讨论】:

  • 您是否删除了 mex 端点?你有没有改变默认配置?发布您的 app/web.config,以便我们验证您的设置。
  • 点击发现时,应用“发现”的url是什么?
  • 还可以尝试浏览 URL:localhost/MyService.svc/_vti_bin/ListData.svc 如果出现内部服务器错误,您将获得有关它的更多信息。如果是这种情况,也可以在这里发布。
  • 我明白了,您可能在某个时候更改了服务的 url,检查您的 .svc 标记文件是否有错误,并检查您的文件名是否与 BicepsSerivce url 匹配。

标签: c# wcf


【解决方案1】:

问题是我在配置中的服务属性中将错误的类型列为 Name,我使用的是接口而不是实现

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-07
    • 1970-01-01
    • 2014-08-22
    • 1970-01-01
    相关资源
    最近更新 更多