10

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.

Benjamin Autin
  • 4,143
  • 26
  • 34

2 Answers2

12

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

Benjamin Autin
  • 4,143
  • 26
  • 34
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.

Lounges
  • 4,674
  • 5
  • 32
  • 43
  • 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. – Benjamin Autin Mar 10 '09 at 05:26
  • The permissions for GET and POST are identical. – Benjamin Autin Mar 10 '09 at 05:35
  • 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 Mar 10 '09 at 16:44
  • HTTP Client exhibits the same behavior I'm experiencing even with GET. Constant authentication requests. – Benjamin Autin Mar 10 '09 at 17:16
  • 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. – Benjamin Autin Mar 10 '09 at 17:18