I am looking for a way to remove the envelope around my SOAP Response. The Data is in JSON but doesnt really have levels so if I can remove the envelope I know I can parse it because I put the data into a json file and got the parser working for it. My only problem when I get the response from the server is the envelope surrounding the data.
I have looked alot but cant seem to find a answer. Any help and sample code is appreciated!
This is my soap response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<AuthenticateUserResponse xmlns="http://tempuri.org/">
<AuthenticateUserResult>{"isValid":true,"isContractor":false,"isExpired":false,"isApproved":true,"userID":"e2be94cb-2e74-4eae-91a9-d874735b8647","userType":"DUMP ","trucks":1}</AuthenticateUserResult>
</AuthenticateUserResponse>
</s:Body>
</s:Envelope>
I am looking to pull this.
{"isValid":true,"isContractor":false,"isExpired":false,"isApproved":true,"userID":"e2be94cb-2e74-4eae-91a9-d874735b8647","userType":"DUMP ","trucks":1}
I could be taking a wrong approach but any help is greatly appreciated.
This may or may not be overkill for your needs, but here’s how I’m doing it.
Get yourself an NSXMLParser. Set its delegate.
In the delegate, look for these methods:
In the didStartElement method, check if elementName is AuthenticateUserResult. If it is, set a boolean isInAuthenticateUserResult = YES;
In the didEndElement method, set that boolean to no.
In the foundCharacters method, if the boolean is YES then the characters are your JSON.