私は iPad アプリを書くのにとても苦労しました。それは 3 枚の写真を撮り、それらを .net SOAP Web サービスに送信します。写真は適切に送信され、サーバーで見ることができます。しかし、問題は、送信ボタンをクリックすると、ボタンが青色のままになり (クリック効果)、アプリがフリーズすることです。
写真をWebサービスに送信する際に何か問題があると思います。私もすべてのリリース作業を行っています。
私のコードを見て、どこが間違っているか教えてください。
- (IBAction)buttonClick:(id)sender {
recordResults = FALSE;
datax = UIImageJPEGRepresentation(u1,0.6);
resultx = [datax base64Encoding];
datax2 = UIImageJPEGRepresentation(u2,0.6);
resultx2 = [datax2 base64Encoding];
datax3 = UIImageJPEGRepresentation(u3,0.6);
resultx3 = [datax3 base64Encoding];
NSString *soapMessage = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<soap:Envelope
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<SendData xmlns=\"http://tempuri.org/\">\n"
"<containerId>%@</containerId>"
"<date_>%@</date_>"
"<image1>%@</image1>"
"<image2>%@</image2>"
"<image3>%@</image3>"
"<question1>%@</question1>"
"<question2>%@</question2>"
"<question3>%@</question3>"
"<question4>%@</question4>"
"<question5>%@</question5>"
"<question6>%@</question6>"
"<notes>%@</notes>"
"<transDate>%@</transDate>"
"<userId>%@</userId>"
"<macId>%@</macId>"
"<sFileID>%@</sFileID>"
"</SendData>"
"</soap:Body>\n"
"</soap:Envelope>\n", @"33", @"2013-09-09", resultx ,
resultx2 ,resultx3 ,@"true" ,@"true", @"true", @"true" ,
@"true" , @"3", @"notes", @"2013-09-09", @"123",
@"mymacid", @"sfileid"];
NSLog(soapMessage);
_lbl_result.text = soapMessage;
NSURL *url = [NSURL URLWithString:@"http://192.168.1.57/service1.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/SendData" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection =
[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
webData = [NSMutableData data];
}
else
{
NSLog(@"theConnection is NULL");
}
//[nameInput resignFirstResponder];
}
-(void)connection:(NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes:[webData mutableBytes]
length:[webData length]
encoding:NSUTF8StringEncoding];
NSLog(theXML);
_lbl_result.text = theXML;
[theXML release];
[connection release];
[webData release];
}