views:

148

answers:

0

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 ..........