HTTP requests are not authorized by the client authentication scheme "Anonymous". The authentication header received from the server is "NEGOTIATE,NTLM"

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/geqinggao/p/3270499.html

Recent projects require Web Service authentication authorization, and there are generally two solutions:

1. Pass through SOAP header authentication.

2. Through Integrated Windows authentication.

I tried it today. The second way to authorize is to first publish the Web service to IIS, then select Authentication, enable Windows Authentication, disable anonymous authentication

Publish the Web servive will be called on the client side, I use VS2008, in the client side project reference right-click Add Service Reference, enter address modify namespace OK

The next step is to write the background calling code:

Multiple authorizations have been attempted, and HTTP requests are always reported without the client authentication scheme "Anonymous" authorization. The authentication header received from the server is "NEGOTIATE,NTLM". The wrong, very no solution ah!

Think it's because. NET 3.5 has compatibility issues with 2.0 Web service by adding service references (WCF references)? Honestly, add the Web service in a WS2005 way and try again:

Because Windows authentication is enabled when publishing a Web service, all references will prompt you for a comfortable user name and password, and the following page is the true "add Web Reference" instead of "Add a service Reference"

Next Backstage code:

privatevoidbutton1_Click(objectsender, EventArgs e)   {       XmlNode x = null;       WSPTIClient.PTIWS.PTIWebService s = newWSPTIClient.PTIWS.PTIWebService();       s.Credentials = newSystem.Net.NetworkCredential("Gerry", "password");       x = s.Transight_RetrieveOrder(1, DateTime.Now.Date, "-1");       MessageBox.Show(x.OuterXml);   }

Run no error, everything OK. Let's see more references to the project. Add a Web Reference

Reference: http://developer.51cto.com/art/200908/141829.htm

HTTP requests are not authorized by the client authentication scheme "Anonymous". The authentication header received from the server is "NEGOTIATE,NTLM"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.