Window 8 metro The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was

      public static ListsService.ListsSoapClient GetService(string uri)

        {

            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();

            binding.MaxReceivedMessageSize =int.MaxValue;

            binding.MaxBufferSize =int.MaxValue;

            binding.Security.Mode =BasicHttpSecurityMode.TransportCredentialOnly;

            binding.Security.Transport.ClientCredentialType =HttpClientCredentialType.Ntlm;

           if (uri != null)

            {

                System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(uri);

                 try

                 {

                   return new ListsService.ListsSoapClient(binding, address);

                }

              catch (Exception)

                {

                }

            }

          return null;

        }

posted @ 2012-11-30 16:21  一休上香  阅读(225)  评论(0编辑  收藏  举报