tags:

views:

1665

answers:

2

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.

A: 

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.

Lounges
The web client works fine and if I create a .Net application, that works fine as well. But I guess I could check the permissions just in case.
toast
The permissions for GET and POST are identical.
toast
Are you sure? Something the POST function is doing might require authentication such as writing to a file. The .NET client is most likely authenticating for you. Have you tried making the call in an HTTP Debugger? http://ditchnet.org/httpclient/
Lounges
HTTP Client exhibits the same behavior I'm experiencing even with GET. Constant authentication requests.
toast
Further more, I am trying to authenticate every time it asks. And in the .Net and iPhone applications, I'm using the same credentials. So I don't see how one can somehow be authentication more than the other.
toast
+7  A: 

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

toast
Thanks! ASIHTTPRequest was just what I was looking for.
Dana