使用域凭据连接到Windows Phone 8(C#)中的WCF服务
我有一个WindowsPhone8项目(用C#)和一个服务参考。是否可以将http客户端凭据类型设置为NTLM?我需要提供域名,用户和密码 我正在使用BasicHttpBinding和TransportCredentialOnly选项。这是在一个小时内完成的 *.ClientConfig文件:使用域凭据连接到Windows Phone 8(C#)中的WCF服务,c#,wcf,windows-phone-8,C#,Wcf,Windows Phone 8,我有一个WindowsPhone8项目(用C#)和一个服务参考。是否可以将http客户端凭据类型设置为NTLM?我需要提供域名,用户和密码 我正在使用BasicHttpBinding和TransportCredentialOnly选项。这是在一个小时内完成的 *.ClientConfig文件: <configuration> <system.serviceModel> <bindings> <basicHttpBinding>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSSoap" maxBufferSize="XXX" maxReceivedMessageSize="XXX">
<security mode="TransportCredentialOnly" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://<address>" binding="basicHttpBinding"
bindingConfiguration="WSSoap" contract="WorkListService.WSSoap"
name="WSSoap" />
</client>
</system.serviceModel>
</configuration>
我没有任何手机开发经验。我在C#服务级别的工作在哪里
Uri uri = new Uri("http://whatever.com");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
NetworkCredential networkCredentials = new NetworkCredential();
networkCredentials.Domain = "Domain";
networkCredentials.UserName = "User";
networkCredentials.Password = "Pass";
CredentialCache cc = new CredentialCache();
cc.Add(uri, "Basic", networkCredentials); //NTLM can be used here, but Basic usually works.
request.Credentials = cc;
request.Method = WebRequestMethods.Http.Get;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
...
}
Uri uri = new Uri("http://whatever.com");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
NetworkCredential networkCredentials = new NetworkCredential();
networkCredentials.Domain = "Domain";
networkCredentials.UserName = "User";
networkCredentials.Password = "Pass";
CredentialCache cc = new CredentialCache();
cc.Add(uri, "Basic", networkCredentials); //NTLM can be used here, but Basic usually works.
request.Credentials = cc;
request.Method = WebRequestMethods.Http.Get;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
...
}