WCF web服务在部署后不工作

WCF web服务在部署后不工作,wcf,visual-studio-2010,web-services,Wcf,Visual Studio 2010,Web Services,我正在尝试创建一个WCF web服务,它允许其他应用程序通过向该服务url发出http请求来检索字符串。我尝试在IIS中发布该服务,当尝试使用url浏览到它时,它会显示它 ' The resource cannot be found' 当我检查文件夹的路径时,我使用了url, 我得到了错误 'No protocol binding matches the given address 'http://localhost:xxxx/WcfSampleLibrary/Service1/mex.'

我正在尝试创建一个WCF web服务,它允许其他应用程序通过向该服务url发出http请求来检索字符串。我尝试在IIS中发布该服务,当尝试使用url浏览到它时,它会显示它

' The resource cannot be found'
当我检查文件夹的路径时,我使用了url, 我得到了错误

'No protocol binding matches the given address 
'http://localhost:xxxx/WcfSampleLibrary/Service1/mex.' 
 Protocol bindings are configured at the Site level in IIS or WAS configuration'
以下是已发布文件夹的目录路径:

C:\inetpub\wwwroot\WcfServices\WcfSampleLibrary\WcfSampleLibrary.Service1
C:\inetpub\wwwroot\WcfServices\WcfSampleLibrary\Web.config
C:\inetpub\wwwroot\WcfServices\WcfSampleLibrary\bin\WcfSampleLibrary.dll
web配置文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<system.web>
    <compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
  <service name="WcfSampleLibrary.Service1" behaviorConfiguration ="mex">
    <host>
      <baseAddresses>
        <add baseAddress = "http://192.xxx.x.xxx/WcfSampleLibrary/Service1/" />
      </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <endpoint address ="" 
      binding="wsHttpBinding"  contract="WcfSampleLibrary.IService1">
     <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
   <endpoint address="http://localhost:xxxx/WcfSampleLibrary/Service1/mex" name="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="mex">
     <serviceMetadata httpGetEnabled="false"/>
      <!-- To receive exception details in faults for debugging purposes, 
      set the value below to true.  Set to false before deployment 
      to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>


在IIS托管的WCF服务中,您没有在地址中指定完整URI。IIS决定地址。此外,在IIS中托管时,
baseAddresses
元素被完全忽略(因此请将其从Web.config中删除)。服务的基址由放置wcf服务的网站和虚拟目录确定。请执行以下操作:

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

启用
httpGetEnabled
后,浏览服务URI将为您提供查看WSDL的选项。

您将其发布到同一台计算机上的IIS,并设置为在端口
xxxx
上侦听?您的
基地址与您的服务端点
地址
不同。通常您可以完全省略
基本地址
;它会自行设置端口如果我删除基址,我可以更改端点地址以使用其中的ip,以便可以从Lant中访问它吗谢谢您的解释…我尝试了这些更改,但现在出现错误:web服务器配置为不列出此目录的内容..在IIS中使用浏览站点时。当我在浏览器中手动键入整个url时,它返回找不到的资源…这只是一个安全/共享问题吗。AlsoIT可能不会列出目录的内容(您可以在IIS管理员中打开它),但至少您可以获得web服务器用来承载它的URI。web文件夹中有哪些文件?您是否有
ServiceName.svc
文件?该服务文件不在web文件夹中;我在bin文件夹中有WcfSampleLibrary.dll,在主文件夹中有web.config文件。我应该手动添加服务文件吗?是。还要确保.svc文件引用的是bin/文件夹中的.DLL。因此.svc文件的第一行有:
服务的值应该引用bin文件夹中的程序集。
<behaviors>
  <serviceBehaviors>
    <behavior name="mex" >
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>