2013-12-19 84 views
0

错误WCF WebService的错误

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"; 
     } 
    } 
+0

您能否显示.svc文件的内容? – Chris

+0

您有'mexHttpsBinding' - 可能将其更改为'mexHttpBinding',或将测试客户端更改为指向本地HTTPS端点? – StuartLC

+0

@克里斯: 标记:<%@ ServiceHost的语言= “C#” 调试= “真” 服务= “MvcApplication4.WS.Service1” 代码隐藏= “Service1.svc.cs” %> C#代码: 命名空间的Web .WebServices { [ServiceBehavior(AddressFilterMode = AddressFilterMode。任何)] 公共类传统:ILegacy { 公共字符串DoWork() { return“OK”; } } } –

回答

0
  1. 将只是简单的文件在网站目录(hello.html的),并检查是否可达(的helloworld.html)

    的Hello World 的Hello World!

如果不工作 - 检查IIS的绑定设置,以及该服务是否和它的应用程序池上。

  1. 在IIS配置上,选择'功能视图',然后转到'目录浏览'+启用。
  2. 在svc放完之后:... svc?wsdl
  3. 首先检查一下你自己的本地环境。一切正常后,您可以从网上查询。
  4. 在Visual Studio上,您应该通过创建新网站(新文件夹)并将结果复制到网站(包括web.config)来完成基本操作 - 有一个默认的源代码。你可以添加新的函数来服务(即helloworld,它返回一个字符串,并在iservices上引用它)。 如果没有创建svc文件(旧的VS版本) - 你可以创建自己的文本文件,并做一些复制+粘贴修复svc文件...在网站上,应该有app_code和app_data文件夹。

希望有所帮助。 祝你好运!