【发布时间】:2011-02-04 13:52:39
【问题描述】:
开始之前:我正在使用 Objective C 为 Iphone 编程。
我已经使用 NSURLRequest 和 NSURLConnection 实现了对 Web 服务函数的调用。然后该函数返回一个包含我需要的信息的 XML。
代码如下:
NSURL *url = [NSURL URLWithString:@"http://myWebService/function"];
NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url];
NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
我也实现了方法
- didRecieveResponse
- didRecieveAuthenticationChallenge
- didRecievedData
- didFailWithError
- connectionDidFinishLoading.
而且效果很好。
现在我需要向函数发送 2 个参数:“位置”和“模块”。
我尝试使用以下修改:
NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url];
[theRequest setValue:@"USA" forHTTPHeaderField:@"location"];
[theRequest setValue:@"DEVELOPMENT" forHTTPHeaderField:@"module"];
NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
但它似乎不起作用。 我做错了什么?有没有办法知道我是否使用了错误的参数名称(可能是“位置”或“位置”,或者没关系?)? 或者知道函数在等待哪些参数的方法...
额外信息:
我无权访问 Web 服务的源代码,因此无法对其进行修改。
但我可以访问 WSDL。制作函数的人都在那里......但我无法理解它>.<......>
任何帮助将不胜感激。 :)
【问题讨论】:
-
是的!我认为 headerFields 不是这样做的地方......但我很绝望 XD
-
如果您可以访问 WSDL,您可能需要查看 wsdl2objc:code.google.com/p/wsdl2objc
标签: iphone objective-c web-services parameters