簡體   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