I have an project in which i retrieve data from user and save in local xml file. I have done all this on simulator. Now i want to deploy on iPhone device. But problem is that how send file (XML) from iphone to server by using web services?
Asked
Active
Viewed 853 times
1
-
Can you please explain what webservice you use? Or do you have to write it yourself? – Sandro Meier Jul 19 '11 at 10:52
-
No i don't write anything. Can u tell me how do that? Idon't have any idea. – ram Jul 19 '11 at 10:57
-
It's an other programming language. I use PHP to write webservices. Because in my opinion it's very similar to Objective-c. ;-) – Sandro Meier Jul 19 '11 at 11:05
-
So u please tell me what ever u use web service. – ram Jul 19 '11 at 11:09
-
I can't share them with you because they are private and do just straightforward task like a password restore... ;-) – Sandro Meier Jul 19 '11 at 11:10
-
why not u tell me only structure of that/ – ram Jul 19 '11 at 11:20
-
@SandroMeier let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/1616/discussion-between-ram-and-sandro-meier) – ram Jul 19 '11 at 11:21
1 Answers
1
You can HTTP POST it:
NSString * xmlString = @"<test><message length="5">Hello</message></test>";
NSURL * serviceUrl = [NSURL URLWithString:@"http://my.company.com/myservice"];
NSMutableURLRequest * serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl];
[serviceRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
[serviceRequest setHTTPMethod:@"POST"];
[serviceRequest setHTTPBody:[xmlString dataUsingEncoding:NSASCIIStringEncoding]];
NSURLResponse * serviceResponse;
NSError * serviceError;
serviceResponse = [NSURLConnection sendSynchronousRequest:serviceRequest returningResponse:&serviceResponse error:&serviceError];
Taken from here

Community
- 1
- 1

Man of One Way
- 3,904
- 1
- 26
- 41
-
We need more information about your Webservice. Else we can't help you. ;-) – Sandro Meier Jul 19 '11 at 11:05
-
As you can see above, you have an XML string and a web service, then you send a request to the web service and get a response. Pretty straightforward. – Man of One Way Jul 19 '11 at 11:06
-