iPhone Web App: Accessing Webservice with user name and password
I was in to development of a Web App for iPhone and after the development got over we had to deploy it in a server. We deployed it. And then the game started.
Our Application internally accessed a webservice from a server which has to be authenticated with the user name and password. And we thought everything would go fine. We tested it in Safari, Chrome and it did work as expected but with a huge delay in displaying the data. Finally we tried in iPhone Safari. And to our frustration, it thrown us unauthorized (401) message. So we tried setting user name and password in open() of xmlHttp object but to no avail in iPhone safari.
Then I tried to setting Authorization Request header and it threw me a message like “Unsafe Header is set”. So Finally after a period of over 3 days struggle I stumble upon this thread where a ratranch had suggested the solution, where we had to format our URL in the following manner:
Then I tried this option and for heavens sake it worked and I became a relieved man. 🙂
And to me it seems that this problem is specific to iPhone Safari. I still have not tested it in Android, would test it in Android Browser and update sooner.
Hope this would help some one in search of this solution in web.