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 应用程序使用相同的服务时,我得到了这个异常
The HTTP request is unauthorized with client authentication scheme
'Negotiate'. The authentication header received from the server was
'Negotiate,NTLM'.
- 在 IIS Local 上部署 WCF 服务(因为 IIS Express 不太灵活),启动匿名身份验证并设置 Windows 集成身份验证。
- 在目标 Win 8 应用程序中引用服务。
在使用服务代理之前添加带有标识的行:
var client = new ServiceReference1.Service1Client();
client.ClientCredentials.Windows.ClientCredential.UserName = "windows user name";
client.ClientCredentials.Windows.ClientCredential.Password = "user passw";
调用服务方法
- 利润
我写了一个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 应用程序使用相同的服务时,我得到了这个异常
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'.
- 在 IIS Local 上部署 WCF 服务(因为 IIS Express 不太灵活),启动匿名身份验证并设置 Windows 集成身份验证。
- 在目标 Win 8 应用程序中引用服务。
在使用服务代理之前添加带有标识的行:
var client = new ServiceReference1.Service1Client(); client.ClientCredentials.Windows.ClientCredential.UserName = "windows user name";
client.ClientCredentials.Windows.ClientCredential.Password = "user passw";调用服务方法
- 利润