Jump to content


Photo

Uploading Xml With Nsinputstream


  • Please log in to reply
No replies to this topic

#1 Rashi Mahajan

Rashi Mahajan

    New Member

  • Members
  • Pip
  • 1 posts

Posted 04 May 2010 - 09:51 AM

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users