繁体   English   中英

WCF basicHttpBinding在Windows 8.1应用商店中不起作用

[英]Wcf basicHttpBinding not working in Windows 8.1 app store

我写了一个Wcf服务,它的配置文件是

  <system.serviceModel>    
      <behaviors>
        <serviceBehaviors>
          <behavior name="MyServiceTypeBehaviors" >
            <serviceMetadata httpGetEnabled="true"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="securityDemo">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Windows" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfDemo.EmpService"  behaviorConfiguration="MyServiceTypeBehaviors">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:3003/"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="basicHttpBinding" contract="WcfDemo.IEmpService" bindingConfiguration="securityDemo"/>
      </service>
    </services>
  </system.serviceModel>

对于控制台应用程序或WPF应用程序,此工作正常。 但是,当我为Windows 8.1应用程序使用相同的服务时,却收到此异常

客户端身份验证方案“协商”未授权HTTP请求。 从服务器收到的身份验证标头是“ Negotiate,NTLM”。

  • 在IIS Local上部署WCF服务(因为IIS Express不太灵活),关闭“匿名身份验证”并在Windows集成身份验证上设置。
  • 在目标Win 8应用程序中进行服务引用。
  • 在使用服务代理之前,添加带有标识的行:

    var client = new ServiceReference1.Service1Client(); client.ClientCredentials.Windows.ClientCredential.UserName =“ Windows用户名”;
    client.ClientCredentials.Windows.ClientCredential.Password =“用户密码”;

  • 调用服务方法

  • 利润

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM