问题
I'm trying to access some web services in an iPhone application.
If I GET
to the .asmx page, I authenticate and get the WSDL as expected.
However, if I POST
to the .asmx page, setting the SOAPAction, Content-Type, Content-Length, and HTTPBody, I just keep getting didReceiveAuthenticationChallenge
messages.
Additionally, I'm trying to POST to IIS using Integrated Windows Authentication (IWA), which means I'm trying to negotiate an NTLM challenge.
回答1:
I unfortunately found my answer. NSURLConnection cannot do NTLM authentication. Here's a post about how to do NTLM authentication using the CFNetwork stack.
HTTP Post via the CFNetwork stack
Found something even better than doing all of that tediousness: Someone who has already done it!
ASIHTTPRequest
Update: There is a workaround for iOS 4 that allows for NTLM authentication again
回答2:
Sounds to me like your web-service has different read (get) and write (post) permissions. I dont think this is an issue with the iPhone or NSURLConnection at all.
来源:https://stackoverflow.com/questions/628935/how-to-perform-an-ntlm-challenge-on-the-iphone