iOS调用Webservice的问题,不能传递参数,请问有一般是哪里出错了

cd_chen 发布于 2016/09/08 16:50
阅读 601
收藏 0
iOS
  1. NSString *webServiceBodyStr = [NSString stringWithFormat:
  2. @"<getFamilyListByMobile xmlns=\"http://service.family.com/\">\n"
  3. "<mobile>%@</mobile>\n"
  4. "</getFamilyListByMobile>",@"13428990840"];//这里是参数
  5. NSString *webServiceStr = [NSString stringWithFormat:
  6. @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  7. "<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"
  8. "<soap:Body>\n"
  9. "%@\n"
  10. "</soap:Body>\n"
  11. "</soap:Envelope>",
  12. webServiceBodyStr];//webService头
  13. NSString *SOAPActionStr = [NSString stringWithFormat:@"http://service.family.com/%@", @"getFamilyListByMobile"];//SOAPAction
  14. NSURL *url = [NSURL URLWithString:@"http://112.74.206.248:8080/family/service/myfamily?wsdl"];
  15. NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
  16. NSString *msgLength = [NSString stringWithFormat:@"%ld", webServiceStr.length];
  17. [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-type"];
  18. [theRequest addValue:SOAPActionStr forHTTPHeaderField:@"SOAPAction"];
  19. [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
  20. [theRequest setHTTPMethod:@"POST"];
  21. [theRequest setHTTPBody:[webServiceStr dataUsingEncoding:NSUTF8StringEncoding]];
  22. NSURLConnection *theConn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
  23. if (theConn) {
  24. }else {
  25. }


上面是代码,能请求成功,但是后台获取不到传递的参数.

返回以下信息:[{"message":"mobile不能为空","data":"","state":200}]

各位兄弟有时间的能帮我看看哪里出了问题么.后端是用Java写的


加载中
返回顶部
顶部