Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
856 views
in Technique[技术] by (71.8m points)

c# - WCF Test Client cannot add service, cannot obtain metadata

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...