开发者

post xmldata through webservice iphone problem

开发者 https://www.devze.com 2023-03-10 09:04 出处:网络
This is my xml NSString *Message = [NSString stringWithFormat: @\"<?xml version=\\\"1.0\\\" encoding=\\\"utf-8\\\"?>\\n\"

This is my 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);

I have simply pass this category id and get the result but returnString always display all category details. I didn't get an exact result. Is this the correct way of passing xml data to webservice?


go and search for 'wsdl2objc' it does it all for you if you wanted to do soap requests.


This code will work perfectly. the problem is webservice page

0

精彩评论

暂无评论...
验证码 换一张
取 消