我相信这对你们专家来说非常简单。SUDZC 已设置,一切似乎都正常工作,但是当一个值返回给委托时,它为空。NSLog 显示正确的 XML 响应,所以我知道它工作正常,但代码中的值显示为 null。SUDZC 附带一个示例程序,这就是它的运行方式。我在返回“低俗小说”的网络服务“WhatsYourFavoriteMovie”上创建了一个测试函数。日志清楚地显示了这个值被返回。为什么最终值(null)?请帮忙,谢谢。
所以我打电话...
[service WhatsYourFavoriteMovie:self action:@selector(WhatsYourFavoriteMovieHandler:) userid: 1];
然后当网络服务响应它去...
// Handle the response from WhatsYourFavoriteMovie.
- (void) WhatsYourFavoriteMovieHandler: (id) value {
// Handle errors
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
// Do something with the NSString* result
NSString* result = (NSString*)value;
NSLog(@"WhatsYourFavoriteMovie returned the value: %@", result);
}
但是“值”和“结果”始终为“空”......正如您在下面的 NSLog 输出中看到的那样,它在标签中返回“低俗小说”。我哪里错了?
2012-02-17 17:27:41.487 SudzCExamples[2782:f803] Loading: https://www.mydomain.com/tk_services/tk.asmx
2012-02-17 17:27:41.491 SudzCExamples[2782:f803] <?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/"
xmlns="com.mynamespace"><soap:Body><WhatsYourFavoriteMovie>
<userid>1</userid></WhatsYourFavoriteMovie></soap:Body></soap:Envelope>
2012-02-17 17:27:41.497 SudzCExamples[2782:f803]
Applications are expected to have a root view controller at the end of application launch
2012-02-17 17:27:45.947 SudzCExamples[2782:f803]
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>
<WhatsYourFavoriteMovieResponse xmlns="com.mynamespace">
<WhatsYourFavoriteMovieResult>Pulp Fiction</WhatsYourFavoriteMovieResult>
</WhatsYourFavoriteMovieResponse></soap:Body></soap:Envelope>
2012-02-17 17:27:45.949 SudzCExamples[2782:f803] WhatsYourFavoriteMovie returned the value: (null)"
再一次,正如您在日志中看到的那样,它从服务器获得了值“pulp小说”,但日志的最后一行显示它返回值“null”。请帮我!!谢谢你。