#import
#import
@interface iCHT_Comm : NSObject{
NSURL *urlData;
NSString *sendXmlData;
NSString *recvXmlData;
NSData *nsRecvData;
}
@property (nonatomic, retain) NSURL *urlData;
@property (nonatomic, retain) NSString *sendXmlData;
@property (nonatomic, retain) NSString *recvXmlData;
@property (nonatomic, retain) NSData *nsRecvData;
- (void)conSendXmlData;
@end
#import "iCHT_Comm.h"
@implementation iCHT_Comm
@synthesize sendXmlData,urlData,recvXmlData,nsRecvData;
- (void)conSendXmlData
{
NSError *error = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlData
cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30];
[request setHTTPMethod:@"POST"];
[request setValue:@"text.html" forHTTPHeaderField:@"Content-Type"];
NSData *postData = [sendXmlData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
NSInputStream *is = [NSInputStream inputStreamWithData:postData];
[request setHTTPBodyStream:is];
nsRecvData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
recvXmlData = [[NSString alloc] initWithData:nsRecvData encoding:NSUTF8StringEncoding];
NSLog(@"recvXmlData[%@]",recvXmlData);
}
@end
阅读(1711) | 评论(0) | 转发(0) |