Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Test Client cannot add service, cannot obtain metadata

Tags:

c#

metadata

wcf

Can anyone tell me why I get this error when I try to add my service?

Error: Cannot obtain Metadata from http://myserver/myapp. 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://myserver/myapp Metadata contains a reference that cannot be resolved: 'http://myserver/myapp'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI: http://myserver/myapp There was an error downloading 'http://myserver/myapp'. The request failed with HTTP status 403: Forbidden.

Update: I have the following endpoint already,

<endpoint address="mex" 
          binding="mexHttpBinding"
          name="Metadata"
          contract="IMetadataExchange" />

I also have the service behaviors set:

  <serviceBehaviors>
    <behavior name="myBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
like image 489
hyprsleepy Avatar asked Feb 02 '12 15:02

hyprsleepy


People also ask

Can not obtain metadata from WCF service?

Error: Cannot obtain Metadata from http://xxxxxxx/WcfService1/Service1.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.

How do I enable metadata publishing at the specified address in WCF?

Metadata endpoints are similar to other service endpoints in that they have an address, a binding, and a contract, and they can be added to a service host through configuration or in code. To enable publishing metadata endpoints, you must add the ServiceMetadataBehavior service behavior to the service.


1 Answers

I had this issue, turns out that when I renamed the .svc file a reference to it hadn't been renamed from Service1.svc. Run a project wide search and replace .Service1 with your new name.

<%@ ServiceHost Language="C#" Debug="true" Service="MyNamespace.Service1" CodeBehind="MyRenamedService.svc.cs" %>

Service="MyNamespace.Service1" should read Service="MyNamespace.MyRenamedService"

like image 111
GJKH Avatar answered Sep 18 '22 08:09

GJKH