3
votes

When I try to run my application from the WCF Test Client I receive the following error:

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.

Here is 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've no idea what could be causing this? My Membership Provider is in that location and it has the correct namespace.

1
Have you tried going to that url and seeing if you get a specific error from the page? Browsing to the URL of the service has saved me a lot of time when trying to debug config errors.deltree
I don't see any endpoints defined in your config?Rajesh

1 Answers

6
votes

Remove the name attribute from

   <behavior name="MyServiceBehavior"> 

and from

   <binding name="MembershipBinding">

and add serviceMetadata element

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

            </behavior>
        </serviceBehaviors>
    </behaviors>