0

多くの方法を試しましたが、サーバー側でまだ空の配列を取得しています。

これが私のコードです:

NSString *urlString = [[NSString alloc] initWithFormat:@"%@/test.php", APP_WEBSITE_URL];    
NSURL *requestURL = [NSURL URLWithString:urlString]; 
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

[requestObj setHTTPMethod:@"POST"];             
[requestObj setValue:@"application/xml" forHTTPHeaderField:@"Content-Type"];

NSInteger tmpCount = [strawPollDetailItem.selectionsArray count];

NSMutableData *postBody = [NSMutableData data];

[postBody appendData:[[NSString stringWithFormat:@"<SUBMITTED>"] dataUsingEncoding:NSUTF8StringEncoding]];
for (int i=0; i<tmpCount; i++) {

    NSInteger selectedID = [strawPollDetailItem.selectionsArray objectAtIndex:i];

    [postBody appendData:[[NSString stringWithFormat:@"<OPTIONID>%@</OPTIONID>", selectedID] dataUsingEncoding:NSUTF8StringEncoding]];
}

[postBody appendData:[[NSString stringWithFormat:@"</SUBMITTED>"] dataUsingEncoding:NSUTF8StringEncoding]];
[requestObj setHTTPBody:postBody];
[[NSURLConnection alloc] initWithRequest:requestObj delegate:self];
4

1 に答える 1

0
    NSURL * serviceUrl = [NSURL URLWithString:@"weblink"];
    NSMutableURLRequest * serviceRequest = [NSMutableURLRequest requestWithURL:serviceUrl];
    [serviceRequest setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
    //[serviceRequest setValue:txtTitle.text forHTTPHeaderField:@"title"];
    [serviceRequest setHTTPMethod:@"POST"];
    [serviceRequest setHTTPBody:[xmlString dataUsingEncoding:NSASCIIStringEncoding]];
    [serviceRequest setValue:[NSString stringWithFormat:@"%d",[xmlString length]] forHTTPHeaderField:@"Content-Length"];
    NSURLResponse * serviceResponse;
    NSError * serviceError;

    NSData *responseData = [NSURLConnection sendSynchronousRequest:serviceRequest returningResponse:&serviceResponse error:&serviceError];
    NSString *responseString = [[[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding] autorelease];
于 2012-07-09T13:41:57.637 に答える