我正在尝试将WCF服务部署到我的服务器,托管在IIS中。当然它适用于我的机器:)
但是当我部署它时,我收到以下错误:
此集合已包含 地址与方案http。有可以 每个计划最多一个地址 这个系列。
在Google上搜索,我发现必须将serviceHostingEnvironment元素放入web.config文件中:
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
但是一旦我完成了这项工作,我就会得到以下结论:
无法找到该基地址 匹配端点的方案http 绑定BasicHttpBinding。 注册的基地址方案是 [HTTPS]。
它似乎不知道基地址是什么,但我该如何指定呢?这是我的web.config文件的相关部分:
<system.serviceModel>
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://mywebsiteurl"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior name="WcfPortalBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IWcfPortal"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
receiveTimeout="00:10:00" sendTimeout="00:10:00"
openTimeout="00:10:00" closeTimeout="00:10:00">
<readerQuotas maxBytesPerRead="2147483647" maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
<endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal"
bindingConfiguration="BasicHttpBinding_IWcfPortal">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
有人可以了解正在发生的事情以及如何解决这个问题吗?
答案 0 :(得分:41)
尝试将安全模式从“传输”更改为“无”。
<!-- Transport security mode requires IIS to have a
certificate configured for SSL. See readme for
more information on how to set this up. -->
<security mode="None">
答案 1 :(得分:4)
您的IIS配置为在连接到您的站点/应用程序时是否需要SSL?
答案 2 :(得分:4)
如果要在web.config中使用baseAddressPrefixFilters,则还必须设置IIS(6)。这对我有所帮助:
1 /在IIS中找到您的网站。 2 /属性/网站(标签)/ IP地址 - &gt;高级按钮 3 /在将在web.config中使用的同一端口上添加新的主机头。
答案 3 :(得分:4)
我必须对网站/应用程序的IIS配置做两件事。我的问题与在IIS网站应用程序中运行net.tcp有关:
首先:
第二
答案 4 :(得分:2)
只接收列表中的第一个基地址(来自IIS)。 在.NET4之前,每个方案不能有多个基址。
答案 5 :(得分:1)
解决方案是在Web.Config文件中定义自定义绑定,并将安全模式设置为“Transport”。然后,您只需要使用端点定义中的bindingConfiguration属性指向自定义绑定。
答案 6 :(得分:0)
如果它托管在IIS中,则无需指定基址,它将是虚拟目录的地址。
答案 7 :(得分:0)
应该有一种方法可以通过外部配置部分和一个额外的部署步骤轻松解决这个问题,该步骤将特定于部署的外部.config文件放入已知位置。我们通常使用此解决方案来处理不同部署环境(暂存,QA,生产等)的不同服务器配置,如果没有特殊副本,我们的“dev box”将成为默认设置。
答案 8 :(得分:0)
确认我的修复:
在您的web.config文件中,您应该将其配置为:
<system.serviceModel >
<serviceHostingEnvironment configSource=".\Configurations\ServiceHosting.config" />
...
然后,构建一个如下所示的文件夹结构:
/web.config
/Configurations/ServiceHosting.config
/Configurations/Deploy/ServiceHosting.config
基本serviceHosting.config应如下所示:
<?xml version="1.0"?>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
而/ Deploy中的那个看起来像这样:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://myappname.web707.discountasp.net"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
除此之外,您还需要添加手动或自动部署步骤,以便将文件从/ Deploy复制到/ Configurations中的文件。这对于服务地址和连接字符串非常有效,并且可以节省其他解决方法的工作量。
如果您不喜欢这种方法(可以很好地扩展到服务器场,但在单个计算机上更弱),您可以考虑从主机计算机上的服务部署中添加一个级别的web.config文件并放置serviceHostingEnvironment节点那里。它应该为你级联。