我们在IIS 7中托管了RESTful WCF服务。我们希望http和https都可以使用服务。所以我们为服务主机添加了2个绑定 -
的 HTTP ://service.abc.com
的 HTTPS ://service.abc.com
所有实施单一合同的服务都可以正常运行,但对于实施多个合同的任何服务,我们都会获得 System.ServiceModel.ServiceActivationException 。
只有一种类型的绑定 http 或 https ,一切正常。
任何解决方案?
服务配置 -
<services>
<service behaviorConfiguration="RESTServiceBehavior" name="App.Services.Service1">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="App.Contract.Services.IService1" bindingConfiguration="RESTServiceBinding"></endpoint>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp/>
<restGlobalErrorHandler/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="RESTServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceAuthorization serviceAuthorizationManagerType="App.Services.AuthorizationManager, App.Services" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<bindings>
<webHttpBinding>
<binding name="RESTServiceBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
答案 0 :(得分:0)
我是wcf的新手,但是我已经在stackoverflow上读到了它,如果你的服务有多个合同,那么你必须为每个合同添加引用。如果有4个合同,那么必须创建4个服务参考
答案 1 :(得分:0)
您希望在服务上公开的每个合同都需要两个端点。一个端点用于HTTP,第二个用于HTTPS:
<service behaviorConfiguration="RESTServiceBehavior" name="App.Services.Service1">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding"
bindingConfiguration="RESTServiceBinding" contract="App.Contract.Services.IService1" />
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding"
contract="App.Contract.Services.IService1" />
</service>