I am new to ios development and i am trying to access sharepoint web service from ios but i getting 403 forbidden in response
I have also refer to this link for authenticationbut it doesn't work
Then I try to authenticate using didReceiveAuthenticationChallenge method which i refer from This link
As per the developer.apple.com documentation this method is deprecated and i use willSendRequestForAuthenticationChallenge method
Following is Code
var message:String = "<?xml version='1.0' encoding='utf-8'?><soap12:Envelope xmlns:xsi='http://ift.tt/ra1lAU' xmlns:xsd='http://ift.tt/tphNwY' xmlns:soap12='http://ift.tt/18hkEkn'><soap12:Body><GetList xmlns='http://ift.tt/rrg8m0'><listName>ThemeGallery</listName></GetList></soap12:Body></soap12:Envelope>"
var urlString = "https://domainname/_vti_bin/Lists.asmx"
var url = NSURL(string: urlString)
var req = NSMutableURLRequest(URL: url!)
var msglength = String(countElements(message))
req.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
req.addValue(msglength, forHTTPHeaderField: "Content-Length")
req.addValue("http://ift.tt/Wiluec", forHTTPHeaderField: "SOAPAction")
req.HTTPMethod = "POST"
req.HTTPBody = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
var connection = NSURLConnection(request: req, delegate: self, startImmediately: true)
connection?.start()
Connection Methods
func connection(connection: NSURLConnection, willSendRequestForAuthenticationChallenge challenge: NSURLAuthenticationChallenge) {
if challenge.previousFailureCount == 0
{
var newCredential = NSURLCredential(user: self.username, password: self.password, persistence: NSURLCredentialPersistence.ForSession)
challenge.sender.useCredential(newCredential, forAuthenticationChallenge: challenge)
}
else
{
challenge.sender.cancelAuthenticationChallenge(challenge)
}
}
Parsing method
func connectionDidFinishLoading(connection: NSURLConnection!) {
var xmlParser = NSXMLParser(data: self.mutableData)
xmlParser.delegate = self
xmlParser.parse()
xmlParser.shouldResolveExternalEntities = true
}
Is there any specific rights we have to give for access web services of sharepoint

0 commentaires:
Enregistrer un commentaire