Error: Cannot obtain Metadata from localhost:81/WebServices/Legacy.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: localhost:81/WebServices/Legacy.svc Metadata contains a reference that cannot be resolved: 'localhost:81/WebServices/Legacy.svc'.
我的web.config
<system.serviceModel> <services> <service name="Web.WebServices.Legacy" behaviorConfiguration="serviceBehaviorsZero"> <endpoint address="" name="SspService" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingZero" contract="Web.WebServices.ILegacy" /> <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> </service> </services> <bindings> <basicHttpBinding> <binding name="basicHttpBindingZero"> <security mode="None"> </security> </binding> </basicHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="serviceBehaviorsZero"> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel>
爲什麼我不能夠訪問使用WCF測試客戶端我的web服務?
當我通過URL本地主機接取:81/Web服務/ Legacy.svc在瀏覽器 我得到這個錯誤 文件名,目錄名或卷標語法不正確。
更新:我的.svc文件代碼
<%@ ServiceHost Language="C#" Debug="true" Service="Web.WebServices.Legacy" CodeBehind="Legacy.svc.cs" %>
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class Legacy : ILegacy
{
public string DoWork()
{
return "https";
}
}
您能否顯示.svc文件的內容? – Chris
您有'mexHttpsBinding' - 可能將其更改爲'mexHttpBinding',或將測試客戶端更改爲指向本地HTTPS端點? – StuartLC
@克里斯: 標記:<%@ ServiceHost的語言= 「C#」 調試= 「真」 服務= 「MvcApplication4.WS.Service1」 代碼隱藏= 「Service1.svc.cs」 %> C#代碼: 命名空間的Web .WebServices { [ServiceBehavior(AddressFilterMode = AddressFilterMode。任何)] 公共類傳統:ILegacy { 公共字符串DoWork() { return「OK」; } } } –