Transmit compressed file as xml to an iPhone application - iphone

How do I pass a zip file in xml format to an iPhone?
How do I retrieve to the compressed file using objective C and xcode?

Encode the zip's binary data (e.g. via Base64) and add to the XML data
Transmit the XML to the iOS device (e.g. via ASIHTTPRequest)
Parse the XML to retreive the encoded zip data (e.g. via NSXMLParser, or libxml2 etc.)
Decode the encoded zip data (again, with the same encoding method, e.g. Base64)
Use Apple's pre-built zip library to decompress the decoded data

What do you want to do.. Pass an zipped xml file or want to pass zipped data to an xml file?
Here is the library for packing/unpacking the zip files

Related

How to read actual file contents by name in CSV Data Set config - Jmeter

I was writing JMeter tests for REST API.
Its a post request and we need to send a big xml content in request body.
So I was using CSV Data Set config to parameterize the xml content in body part.
I have created a CSV Data Set config for HTTP Request sampler.
In csv file, I am writing the whole xml content. 1 row for 1 request. It is working fine.
But I found this is bit complex as we have to maintain large lines of xml in csv file.
Is there any way we can write only xml file names or full paths in csv file and CSV DataSet config checks the name and then read the contents of that file and append in request body.
file-abc.xml
file-def.xml
I think this would be easy to maintain as we can have dedicated files for XML content.
Any way to do it using CSV DataSet config?
Or any other way to achieve the same in JMeter tests.
I found this question How to hold Xml file names in CSV Data set Config (Jmeter)
I followed its answer but I am not able to pass the xml content in request body.
Its only passing xmlfile names written in csv file in the request body.
But as per answer it reads the file from xml path/name and pass it in the parameter.
You can keep the file names or paths to the files in the CSV file and read the file content using __FileToString() function directly in the HTTP Request sampler body
If you're keeping XML files in a separate folder you might find Directory Listing Config plugin easier to use in case you want to add/remove/rename files without having to maintain the CSV mapping.
Directory Listing Config plugin can be installed using JMeter Plugins Manager

How to upload and encode (base64) a file in webservice using Jmeter

I am new to Jmeter and I need to upload a file and then encrypt the file using base64.
I am able to encode the filename and file path to base64, however I need to both upload and then encrypt the file (base64).
I attempted to use the jmeter custom extension to encode the file, however it encoded the file.
Any ideas on how I can upload the file (text/plain or text/csv or application/excel) and then encode (base64) the file.
Is it possible to specify filetostring function in jmeter ans then encode the string?
You can do this using __FileToString() and __base64Encode() functions combination like:
${__base64Encode(${__FileToString(/path/to/your_file)})}
You can install __base64Encode() function as a part of Custom JMeter Functions bundle using JMeter Plugins Manager
Yes, I managed to resolve the issue. I used the same custom jmeter functions and the __fileToString() function.

MTOM and WS-Security (in CXF)

I am using WS-Security (XML-Signature and XML-Encryption) in my Web Service. For larger, binary objects, I intend to use MTOM.
From what I understood is that the binary data is referenced via something like this:
<xop:include href="SomeUniqueID"/>
I see two problems here:
1) How can I include this binary data in the XML-Signature part of the SOAP header?
2) How can I use XML-Encryption (or to be more specific: CXFs standard ways of "automatically" doing XML-Encryption)?
You can include the data in the XML-Signature as if you were not using MTOM.
When MTOM is enabled, at first, the data will always be encoded in Base64 and then it will be converted to binary data to send it as a MIME attachment.
CXF will use this temporary Base64 representation of your file to include it in the message signature.

How to upload .csv file to server using code in iphone(ios)?

I want to upload .csv file on server while i get .csv file in my project . Can any one help me in that ?
You need to create web service on your server that accepts data of csv file as input.
Then you can use NSURLConnection or use NSData's writeToURL:atomically: method

XML data text + binary

I built an iPhone app that is getting information from a server (this is also a server that I built).
The data from the server is XML and I use the XML parser to parse the message.
What I want is to add an image to be sent from the server, and I am asking if I can add binary data of such an image to the XML message. For example 10 tags will be text and 1 tag will be binary (the image). So when the XML parser gets to the binary tag, it inserts the data to NSDATA object and the rest of the tags will be inserted to NSString.
Does the XML parser of Cocoa can handle this situation?
If not, what do you think will be the easiest way to do this with one connection to the server so that the data from the server is sent once.
To transfer binary data wrapped in XML, encode it using e.g. Base64, which turns your binary data into characters that won't mess up your XML.
You can transfer the image data, encoded using Base64. There is this NSData category by Matt Gallagher that adds Base64 decoding support to NSData (dateFromBase64String). You can find it on his Cocoa with love website.
Mind you that encoding images in Base64 adds about 33% in file size.