在您阅读本文之前,请记住,我是一名 Objective C 程序员,试图与一个对我的工作一无所知的 C# 程序员帮助调试服务器问题。
我正在向 .net/c# 端发送一个 SOAP 数据包,并且服务器接收到变量的空值。当 url 和变量字符串放入浏览器时,我得到了正确的响应。
帖子注销到“?help=1& email=test@email.net & password=testpassword”,但我不断收到“Result=Error&Details=Object reference not set to an instance of an object”。返回我的返回字符串。
NSString *post = [NSString stringWithFormat:@"?help=1& email=? & password=%@",userEmail, userPassword];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]init];
[request setURL:[NSURL URLWithString:LOGIN_SERVICE]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
//Submit the Post:
[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
/NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
//Extract Return:
NSString *returnString = [[NSString alloc]initWithData:returnData encoding:NSUTF8StringEncoding];