我相信这对你们这些专家来说是非常简单的。SUDZC已经设置好了,看起来一切正常,但是当一个值返回给委托时,它就是空的。NSLog显示了正确的XML响应,所以我知道它工作正常,但是代码中的值显示为空。SUDZC附带了一个示例程序,它是这样运行的。我在web服务"WhatsYourFavoriteMovie“上创建了一个测试函数,它返回”低俗小说“。日志记录清楚地显示了返回的这个值。为什么最后的值(null)??请帮帮忙,谢谢。
所以我打电话给...
[service WhatsYourFavoriteMovie:self action:@selector(WhatsYourFavoriteMovieHandler:) userid: 1];然后,当web服务响应时,它会转到...
// 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);
}但是"value“和"result”总是“null”...正如您在下面的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“,但日志的最后一行显示返回值为”null“。请帮帮我!!谢谢。
发布于 2012-03-28 05:32:11
我在Sudzc生成的代码的ARC版本中遇到了完全相同的问题,但无论出于什么原因,非ARC版本都工作得很好
更新
看看这个issue report。我做了第一个注释中建议的更改,ARC版本运行良好。
发布于 2012-02-23 20:30:38
一定要尝试在didrecivedata中NSLog响应。在SoapRequest.m类中
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)value {
NSString *str=[[NSString alloc]initWithData:value encoding:NSUTF8StringEncoding];
NSLog(@"data receives %@",str);
}然后你就会知道确切的问题是什么了。发布回复后,我们将帮助您根据这一点。
发布于 2012-02-24 17:32:01
如果您使用的是ARC版本,请在SoapRequest中更改该行
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:@"Body"] childAtIndex:0];使用
CXMLNode* element = [[Soap getNode: [doc rootElement] withName:@"soap:Body"] childAtIndex:0];https://stackoverflow.com/questions/9337849
复制相似问题