views:

252

answers:

1

Hey all,

I am working with the iPhone SDK and I have to process a webservice response I receive from an external service.

  1. The response data consists of an XML string that was UTF8-encoded to a byte array.

  2. This byte array is converted to string

  3. This string is put into a XML wrapper element

  4. The wrapper is returned via an HTTP response

Therefore I need to know how to convert the response data back to the XML string it used to be. Unfortunately, I cannot change the way my response is created, so I have to deal with it somehow.

Example of the raw data I get from the webservice:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<s:Body><ExportBytesResponse xmlns="http://knowledgepark-ag.com/webservices/"&gt;
    <ExportBytesResult>PERhdGE+PFJlY29yZCBEQj0iOTk5OTQiIEtleT0iMjA1Mjc0Ij48U2luZ2xlIEl0ZW1JZD0iQVJCUEFLRVQiIFZhbHVlPSIyOTAiIC8+PFNpbmdsZSBJdGVtSWQ9IkhET0tOUiIgVmFsdWU9IjIwNTI3NCIgLz48U2luZ2xlIEl0ZW1JZD0iVkVSQSIgVmFsdWU9IjEuNzEuMzIxMy4xNzU3NyIgLz48U2luZ2xlIEl0ZW1JZD0iRElTIiBWYWx1ZT0iR2VNLCBNw6RyIDEwIDIwMDggIDU6NDFQTTomI3hEO1ouenQuIGV4aXNpdGVydCBrZWluZSBNw7ZnbGljaGtlaXQgZGFzIEJlZW5kZW4gZWluZXMgTW9kdWxzIGR1cmNoIEFiYnJlY2hlbiBvZGVyIEhhcmQtQ2xvc2UtWCB6dSBlcmZhaHJlbi4gQW4gZGllc2VyIFN0ZWxsZSBtw7xzc3RlbiBtZWlzdCBVc2VydmFycyBkZXMgTW9kdWxzIGdlbMO2c2NodCB3ZXJkZW4uIE9kZXIgYW5kZXJlIEF1ZnLDpHVtYWt0aW9uIGR1cmNoZ2Vmw7xocnQgd2VyZGVuLiYjeEE7RUxLRUcgMDYuMDguMjAwOCAwOToyMToxNyYjeEE7JiN4QTsgQmVpc3BpZWxhdWZiYXUgOiYjeEQ7JiN4QTsmbHQ7Q2xv</ExportBytesResult>
</ExportBytesResponse></s:Body>

How do I get back my old xml string representation hidden inside these raw bytes?

Any help is highly appreciated, I feel just stupid right now for not being able to come up with a solution.

Best Regards, David

+1  A: 

ExportBytesResponse is Base64 encoded, so you must first decode that node using something like this.

That will give you an NSString containing the XML. Then you can use NSXMLParser to parse your data.

Frank Shearar
Thanks, that was the issue. Windows Azure AppFabric apparently encodes the byte array in the response with Base64.
David R.