1

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/">
<s:Body><ExportBytesResponse xmlns="http://knowledgepark-ag.com/webservices/">
    <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

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • Is your data in the ExportBytesResult node, or are you asking how to turn that whole thing back into XML? – Frank Shearar Mar 04 '10 at 14:19
  • I want to convert the raw data inside my node back to its original XML representation. This has to work somehow with [NSString stringWithBytes ...] but I could not get it to work with something like that until now. –  Mar 04 '10 at 14:36
  • Ah right. ExportBytesResult's contents are Base64 encoded. – Frank Shearar Mar 05 '10 at 08:34

1 Answers1

1

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.

Community
  • 1
  • 1
Frank Shearar
  • 17,012
  • 8
  • 67
  • 94
  • Thanks, that was the issue. Windows Azure AppFabric apparently encodes the byte array in the response with Base64. –  Mar 06 '10 at 14:17