WCF - 错误:无法获取元数据

WCF - 错误:无法获取元数据

问题描述:

当我尝试从WCF测试客户端收到以下错误我的应用程序:WCF - 错误:无法获取元数据

Error: Cannot obtain Metadata from http://localhost:53867/MyAPI.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.
For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error
URI: http://localhost:53867/MyAPI.svc
Metadata contains a reference that cannot be resolved: 'http://localhost:53867/MyAPI.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:53867/MyAPI.svc .
The client and service bindings may be mismatched.
The remote server returned an error: (415) Unsupported Media Type.HTTP GET Error
URI: http://localhost:53867/MyAPI.svc
The HTML document does not contain Web service discovery information.

下面是一些我的web.config中:

​​

我不知道是什么原因造成的?我的会员供应商位于该位置,并具有正确的名称空间。

+2

您是否尝试过要去那个URL,看如果你得到一个特定的错误从页面?在尝试调试配置错误时,浏览到服务的URL为我节省了大量时间。 – deltree 2012-04-17 14:19:16

+0

我没有看到你的配置中定义的任何端点? – Rajesh 2012-04-17 14:25:34

+0

这是4.0 [简化配置](http://msdn.microsoft.com/en-us/library/ee530014.aspx) – 2012-04-17 14:30:49

<behavior name="MyServiceBehavior"> 

取出name属性和

<binding name="MembershipBinding"> 

,并添加serviceMetadata元素

<behaviors> 
     <serviceBehaviors> 
      <behavior> 
       <serviceMetadata httpGetEnabled="True"/> 
       <serviceCredentials> 
       <userNameAuthentication 
        userNamePasswordValidationMode="MembershipProvider" 
        membershipProviderName="CustomMembershipProvider" /> 
       </serviceCredentials> 

      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
+0

从行为元素中删除名称属性对我有用。谢谢, – 2015-06-25 15:45:55