WCF - Error: Unable to get metadata

When I try to start the application from the WCF test client, I get the following error:

Error: Can not retrieve metadata from http: // localhost: 53867 / MyAPI.svc If this is a Windows (R) Communication Foundation service that you have access to, please check that you have enabled the publication of metadata at the specified address.
To help enable metadata publishing, refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata
URI exchange error : http: // localhost: 53867 / MyAPI.svc
Metadata contains a link which cannot be resolved: "http: // localhost: 53867 / MyAPI.svc".
Content Type application / soap + xml; charset = utf-8 is not supported by the http: // localhost: 53867 / MyAPI.svc service .
Client-service binding may be incompatible.
The remote server responded with an error: (415) Unsupported media type. Error HTTETHTTP
URI: http: // localhost: 53867 / MyAPI.svc The
HTML document does not contain Web service discovery information.

Here are some of my web.config:

    <system.web>
    <compilation debug="true" targetFramework="4.0">
        <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </assemblies>
    </compilation>
    <membership defaultProvider="CustomMembershipProvider">
        <providers>
            <clear/>
            <add name="CustomMembershipProvider" type="Namespace.Models.MyMembershipProvider" />
        </providers>
    </membership>
</system.web>
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="MembershipBinding">
                <security mode ="Message">
                    <message clientCredentialType="UserName"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServiceBehavior">
                <serviceCredentials>
                    <userNameAuthentication
                    userNamePasswordValidationMode="MembershipProvider"
                    membershipProviderName="CustomMembershipProvider" />
                </serviceCredentials>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>

I do not know what could be the reason for this? My membership provider is in this place and has the correct namespace.

+3
source share
1 answer

Remove the name attribute from

   <behavior name="MyServiceBehavior"> 

and from

   <binding name="MembershipBinding">

and add the serviceMetadata element p>

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

            </behavior>
        </serviceBehaviors>
    </behaviors>
+6
source

All Articles