首页 文章

使用浏览器访问Web Service的WCF绑定设置为wsHttpBinding将其作为basicHttpBinding

提问于
浏览
0

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

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

1 回答

  • 0

    解决了它 . 删除了底部的ServiceHostingEnviorment标记,发现它正在使用WsHttpBinding,然后必须让我的服务名称与服务的namespace.class相匹配 . 一旦设置完毕,一切正常 .

相关问题