我刚刚为 WCF 服务生成了安装程序,我正在尝试使用:安装在 wwwroot 的结构如下: http ://bit.ly/11zZ85E
bin 文件夹中包含服务所依赖的所有 dll。实现服务契约的类在其中一个 dll 中定义。所有生成和安装过程都很好。我在 IIS 管理器上有以下内容:
问题是当我尝试在浏览器上访问 wsdl 时,我只能看到:
<%@ ServiceHost Language="VB" Debug="true" Service="MyApplication.ServiceImplementation.LicensingService" CodeBehind="MyApplication.ServiceImplementation.Service.vb" %>
如果我尝试使用 Visual Studio 项目中的添加服务引用,我会看到:
下载时出错
(ServiceAddress)/$metadata 请求失败,HTTP 状态为 404:未找到。元数据包含无法解析的引用:(ServiceAddress) 远程服务器返回了意外响应:(405) 方法不允许。远程服务器返回错误:(405) Method Not Allowed。如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。
我所做的安装程序是使用 Installshield 2010 生成的。
这是我的 Web.Config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation strict="false" explicit="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<services>
<service name="MyApp.ServiceImplementation.Service" behaviorConfiguration="WSSecurityBehavior">
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="Operations" binding="wsHttpBinding" contract="MyApp.ServiceContracts.IService" />
<endpoint binding="wsHttpBinding" name="mex" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WSSecurityBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSSecurityBinding">
<reliableSession enabled="true" ordered="true" />
</binding>
</wsHttpBinding>
</bindings>
<!--protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
<handlers accessPolicy="Read, Script" />
<defaultDocument>
<files>
<clear />
<add value="Service.svc" />
</files>
</defaultDocument>
<httpErrors>
<clear />
</httpErrors>
</system.webServer>
</configuration>