简体   繁体   中英

Wcf basicHttpBinding not working in Windows 8.1 app store

I wrote a Wcf Service and its configuration file is

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

This working fine for a console app or WPF app. But when I am using same service for windows 8.1 app i am getting this exception

The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.

  • Deploy a WCF service on IIS Local (because IIS Express are not so flexible), set off Anonymous Authentication and set on Windows Integrated Authentication.
  • make service reference in target Win 8 app.
  • before using Service proxy add a lines with identification:

    var client = new ServiceReference1.Service1Client(); client.ClientCredentials.Windows.ClientCredential.UserName = "windows user name";
    client.ClientCredentials.Windows.ClientCredential.Password = "user passw";

  • call a service method

  • profit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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