各位我在做afnetworking+webService网络请求的时候 我在不传参数的时候它能正常的获取到值。可是一传值进行请求的时候无法获取到返回数据,返回的数据为空:传参情况
无参情况:
哪个做过这样的功能或者是遇过这样的问题,最终是如何解决的
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>"
"<GetLessonFrame xmlns=\"http://www.myapp.com/\">"
"<xh>%@</xh>"
"<fajhh>%@</fajhh>"
"<zyh>%@</zyh>"
"</GetLessonFrame>"
"</soap:Body>"
"</soap:Envelope>",@"10113120",@"",@""
];
NSString *SOAPActionStr = [NSString stringWithFormat:@"URL%@", @"GetLessonFrame"];
NSURL *url = [NSURL URLWithString:@ "BaseURL"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
[request addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:SOAPActionStr forHTTPHeaderField:@"SOAPAction"];
[request addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *resultStr = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"revicedData%@", resultStr);
if (success) {
success(operation,responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
[operation start];
![](http://img.bbs.csdn.net/upload/201604/25/1461575792_670133.png)
无参情况:
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>"
"<GetZY xmlns=\"http://www.myapp.com/\">"
"</GetZY>"
"</soap:Body>"
"</soap:Envelope>"
];
NSString *SOAPActionStr = [NSString stringWithFormat:@"URL%@", @"GetZY"];
NSURL *url = [NSURL URLWithString:@"BaseURL"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
[request addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:SOAPActionStr forHTTPHeaderField:@"SOAPAction"];
[request addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSString *resultStr = [[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"revicedData%@", resultStr);
if (success) {
success(operation,responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
[operation start];
![](http://img.bbs.csdn.net/upload/201604/25/1461575844_841934.png)
哪个做过这样的功能或者是遇过这样的问题,最终是如何解决的