将 SOAP 请求发送到 .net Web 服务时出错,我在这里遗漏了什么吗?
NSString *str1 = [NSString stringWithFormat:@"<UserId>%@</UserId><Password>%@</Password><Referal>%@</Referal>",u,p,r];
NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" \encoding=\"utf-8\"?>" "<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/\">""<soap:Body>""<getData xmlns=\"http://tempuri.org/\">\n"" <reqXML>%@</reqXML>""</getData>\n""</soap:Body>""</soap:Envelope>", str1];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[theRequest setHTTPMethod:@"POST"];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
我在用
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:theRequest];
我得到的错误是:
Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x7536290 {NSErrorFailingURLKey=http://213.171.205.156/webservice_booking_affiliate_live/bookingengine.asmx, NSLocalizedDescription=Expected status code in (200-299), got 400}
我知道 400 是错误的请求,我需要添加什么吗?
对于 .net 服务,我们是否需要像 Android 一样发送任何其他内容,它们有soapobject.dotnet=true