我正在开发一个RESTful和SOAP的WCF服务,现在它们都需要使用NTLM身份验证。
我还希望公开一个MEX端点,以便其他人可以轻松地引用该服务并使用它。
现在,当我将IIS设置为需要Windows身份验证时,我可以使用REST服务并成功调用服务,但是当我想使用SVCUTIL引用该服务时,它会抛出一个需要匿名的错误。
这是我的web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm">
</transport>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm">
</transport>
</security>
</binding>
</webHttpBinding>
<mexHttpBinding>
<binding name="mexHttpBinding"></binding>
</mexHttpBinding>
</bindings>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" automaticFormatSelectionEnabled="true" helpEnabled="True">
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<services>
<service name="Intel.ResourceScheduler.Service" behaviorConfiguration="Meta">
<clear />
<endpoint address="soap" name="SOAP" binding="basicHttpBinding" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" listenUriMode="Explicit" />
<endpoint address="" name="rest" binding="webHttpBinding" behaviorConfiguration="REST" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" />
<endpoint address="mex" name="mex" binding="mexHttpBinding" behaviorConfiguration="" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp />
</behavior>
<behavior name="WCFBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Meta">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="REST">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
<behavior name="">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- 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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
任何帮助将不胜感激。
答案 0 :(得分:1)
尝试更改mex服务的绑定,它不能与mexHttpBinding一起使用,因为它已禁用安全性。我没有在完全相同的情况下对此进行测试,但在我的情况下,由于安全性,我还必须更改它。
在您的示例中,我会尝试更改它:
<endpoint address="mex" contract="IMetadataExchange" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"/>
要使mex绑定配置更加独立于soap服务绑定配置,还可以定义和使用单独的bindingConfiguration,如
<binding name="secureMexHttpBinding" >
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm">
</transport>
</security>
</binding>
然后更改mex端点
endpoint address="mex" contract="IMetadataExchange" binding="basicHttpBinding" bindingConfiguration="secureMexHttpBinding"/>