【问题标题】:WCF Binding set to wsHttpBinding using browser to access Web Service has it as basicHttpBindingWCF Binding 设置为 wsHttpBinding 使用浏览器访问 Web 服务有它作为 basicHttpBinding
【发布时间】:2016-12-24 18:45:31
【问题描述】:

编写了一个从 BasicHttpBinding 开始的 web 服务,用于简单的服务开发,而不必担心安全性。在将它移动到 Web 服务器时,我将绑定切换到 WsHttpBinding 以及基本身份验证,就像 Web 服务器上的另一个 Web 服务一样。但是,当我浏览到 Web 服务以验证它是否正在运行时,它表示配置的绑定仍然是 BasicHttpBinding。已验证 IIS 指向正确的位置。

在主机('Basic')上配置的身份验证方案不允许在绑定'BasicHttpBinding'('Anonymous')上配置的那些。请确保将 SecurityMode 设置为 Transport 或 TransportCredentialOnly。此外,可以通过 IIS 管理 > 工具,通过 ServiceHost.Authentication.AuthenticationSchemes >property,在应用程序配置文件中的 > 元素中,通过更新绑定上的 ClientCredentialType 属性来解决此问题,或通过调整 HttpTransportBindingElement 上的 AuthenticationScheme 属性。

Web.config

<configuration>
   <appSettings>
   </appSettings>
   <system.web>
      <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
      <bindings>
        <wsHttpBinding>
          <binding name="MyBinder">
            <security mode="Transport">
               <transport clientCredentialType="Basic"></transport>
            </security>
         </binding>
       </wsHttpBinding>
     </bindings>
     <services>
      <service name="MyService">
         <endpoint address=""
                binding="wsHttpBinding"
                bindingConfiguration="MyBinder"
                name="MyEndpoint"
                contract="MyService.IMyInterface"></endpoint>
      </service>
     </services>
     <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration> 

【问题讨论】:

    标签: c# asp.net web-services wcf iis


    【解决方案1】:

    解决了。删除底部的 ServiceHostingEnviorment 标记并注意到它正在使用 WsHttpBinding 然后必须让我的服务名称与服务的 namespace.class 匹配。一旦设置好,一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-06
      • 2011-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-01
      • 2018-10-08
      • 2023-03-11
      相关资源
      最近更新 更多