Iphone 如何将多个数据发布到web服务器
我有以下将数据发布到web服务器的代码,但它给了我空响应,我有多个数据,它们是:-Iphone 如何将多个数据发布到web服务器,iphone,ios,Iphone,Ios,我有以下将数据发布到web服务器的代码,但它给了我空响应,我有多个数据,它们是:- date, rig, driller, offsider-1, offsider-2, shift , project, supervisoremail, geologistemail, comments, plants[0][name-id], plants[0][start-usage], plants[0][end-usage], consumables[0][category], con
date,
rig,
driller,
offsider-1,
offsider-2,
shift
,
project,
supervisoremail,
geologistemail,
comments,
plants[0][name-id],
plants[0][start-usage],
plants[0][end-usage],
consumables[0][category],
consumables[0][name-id],
consumables[0][used],
consumables[0][code],
consumables[0][description],
我必须发布此数据,我使用此代码发布,但它对我不起作用。请帮帮我
NSURL *url=[NSURL URLWithString:@"http://www.mydor.com.au/staff/dor/idorInsert"];
NSString *post =[[NSString alloc]initWithFormat:@"date=15/08/2012&rig=53&driller=207&offsider-1=131&offsider- 2=236&shift=day&project=24&supervisoremail=24&geologistemail=24&comments=&plants[0][name- id]=286&plants[0][start-usage]=1.0&plants[0][end-usage]=0.0"];
NSLog(post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"here u re");
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"here also called");
NSLog(@"%@",data)
提前感谢。这里有一篇文章演示了如何使用iOS应用程序使用.NET Web服务。您可以使用本文中讨论的技术:
我所做的几乎所有工作都涉及到.NET和iOS。看看我写的网络类,它一直都是基于网络的。我更喜欢使用常规的aspx表单,而不是ASMXWeb服务。我这样做是因为我不想向窥探访问者公开任何web方法,在以aspx表单返回任何内容之前,我使用API密钥检查。如果您需要,我可以给您发送一个用VB.NET编写的.NET代码示例。您确定您的post字符串就是正文吗?它看起来更像是一个应该附加到URL的查询字符串。嗨,我不知道,我只是通过引用其他网站来使用它,它为我工作登录web服务,我使用字符串username=xx&password=xyz,它可以工作。因此,我不知道如何实现数据。我的Web服务器请求是从koahana php框架发出的,它是否适用于sameCan?您可以告诉我您建议的方法中哪种方法适合我,我可以使用我发布的代码,但需要做一些小的更改,或者我必须按照您的方式进行更改。请告诉我我的方法有什么问题,我是否以错误的方式发送数据,或者故障在哪里。请导游。谢谢。我提到的网络类将被用来代替NSMutableURLRequest和NSURLConnection。network类中的方法非常简单。