WebService is capable of giving response in XML, Plain Text and JSon.
I can successfully get response in XML.
My concern is, how one can get Response in JSon format (not XML or plain text).
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSMutableArray *array = [parser objectWithString:responseString error:nil];
NSString *success = [array valueForKey:@"Successful"];
NSString *token = [array valueForKey:@"Token"];
}
Above is the code for handling the response (Which i did assume JSon, but it was XML).
Hence the app is crashing.
Following is the responce which i am getting:
<AuthenticatedUser xmlns="http://schemas.datacontract.org/2004/07/XYZCOMPANY.ABC.DataContracts.Mobile" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorMsg i:nil="true"/><Successful>true</Successful><Token>MHlc8yKBgghjkfPHZ2oOvabvMWA=</Token></AuthenticatedUser>
if you are not hitting the wrong endpoint you probably need to set the http accept header to “application/json” like @rckoenes said. What you can also do is try to hit the service using CURL or even your web browser to see if the json service is running.
Here is the code it is working for me for requesting a local JSON service created by SOAPUI: