这是我的xml
NSString *Message = [NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<query>\n"
"<IdCategory>1088</IdCategory>\n"
"</query>\n"];
NSURL *url = [NSURL URLWithString:@"http://bvd.vndsupport.com/_ws/api/categories/index.asp"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [Message length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [Message dataUsingEncoding:NSUTF8StringEncoding]];
NSString *returnString = [[NSString alloc] initWithData:[NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil] encoding:NSUTF8StringEncoding];
NSLog(@"%@",returnString);
我只是传递此类别ID并获得结果,但returnString
始终显示所有类别详细信息。我没有得到确切的结果。这是将xml数据传递给webservice的正确方法吗?
答案 0 :(得分:3)
去搜索'wsdl2objc',如果你想做肥皂请求,它会为你完成所有工作。
答案 1 :(得分:1)
此代码将完美运行。问题是webservice页面