Uploading XML with NSInputStream Iphone....

Posted by Aks on Stack Overflow See other posts from Stack Overflow or by Aks
Published on 2010-05-04T18:43:41Z Indexed on 2010/05/04 18:48 UTC
Read the original article Hit count: 339

Filed under:
|

Hi, I have to upload XML string to server & the Web service expect it in body stream part of the http request. So i am allocating the NSInputstream instance with xml data & then setting it the part of the http string but it uploading the stream body NULL & in my code if check the Stream status, it gives error & size null, Could you let me know how to get it done , also pasting the code.

Code: NSInputStream* stream = [[[NSInputStream alloc]initWithData:streamData]retain];

request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:nss_url]]; NSString *msgLength = [NSString stringWithFormat:@"%d", [message length]]; [request addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [request addValue: @"http://www.XYZ.COM/ACL" forHTTPHeaderField:@"SOAPAction"]; [request addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [request setHTTPBodyStream:[NSInputStream inputStreamWithData:streamData]]; [request setHTTPMethod:@"POST"];

NSLog(@"The input stream is %@ & error is %@",[stream streamStatus],[stream streamError]);

Its gives: The input stream is (null) & error is Error Domain=NSUnknownErrorDomain Code=0 "Operation could not be completed. (NSUnknownErrorDomain error 0.)"

Any inputs what I am missing ..........

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsinputstream