【发布时间】:2012-04-27 21:58:50
【问题描述】:
我正在尝试创建一个 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
网页配置文件:
<?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 并设置为侦听端口
xxxx? -
您的
baseAddress与您的服务端点address不同。通常你可以省略baseAddressaltoggether。 -
我没有设置端口,只想使用服务器ip地址;它自己设置端口
-
如果我删除了 baseAddress,我可以更改端点地址以使用其中的 ip,以便可以从 LAN 内访问它
标签: wcf visual-studio-2010 web-services