如何使用 nsurlconnection 与多个 header 进行 Http 请求 post

how to do Http request post using nsurlconnection with multiple header

这是我的代码,请找到更正我找不到为什么没有收到回复
NSString *strNumberKey = @"1234567890"; NSString *strTimeStamp = [[AppDelegate appDelegate]returnTimestamp];//生成随机数

    NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"your_Method_Name",@"MethodName",strTimeStamp,@"RequestUniqueID",[AppDelegate appDelegate].strSessionID,@"SessionID",nil];


    NSString *jsonString = [jsonDictionary JSONRepresentation];
    NSLog(@"Json Format----------%@",jsonString);


    NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat: COMMON_URL_DISTRIBUTOR]] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
    [req setHTTPMethod:@"POST"];
    [req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [req setValue:strNumberKey forHTTPHeaderField:@"Number"];


    NSString *strEncrypt = [FBEncryptorAES encryptBase64String:jsonString keyString:strEncryption];

    [req setValue:[strEncrypt stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]  forHTTPHeaderField :@"Data"];


    NSString* theBodyString = [NSString stringWithFormat:@"Data=%@",strEncrypt];
    NSString* escapedUrlString = [theBodyString stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    NSData *requestData = [escapedUrlString dataUsingEncoding:NSUTF8StringEncoding];

    [req setHTTPBody:requestData];
    (void)[[NSURLConnection alloc] initWithRequest:req delegate:self];

    responseData = [NSMutableData data];

更正 应该是运行希望如此,

NSString* theBodyString = [NSString stringWithFormat:@"Number=%@&Data=%@",strNumberKey,strEncrypt];