我正在开发一个 iPhone 应用程序,我需要在其中使用 Web 服务获取数据。不幸的是,令人惊讶的是,我的 web 服务在 WebApplication 和 iPhone 中使用相同的 url 链接似乎表现不同。我正在使用下面提到的方法从 web 服务获取响应。urlLink 是我传递给下面提到的方法的链接。
NSURL *url = [NSURL URLWithString:urlLink];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];
NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:nil error:nil];
//responseData = [[NSURLConnection alloc] initWithRequest:request delegate:self];
NSLog(@"The data contains..%@",returnData);
responseString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
在 responseString 我应该得到所有的 xml 数据。我的 XML 中有一些节点没有被访问,而在 responseString 中我没有得到一些节点。但是当我使用相同的 url 并尝试在 Web 中检查相同的内容时,我得到了所有节点。我的 XML 看起来像
<Response>
<Switchflag>Y</Switchflag>
<Assignflag>Y</Assignflag>
<Notesflag>N</Notesflag>
<Examflag>Y</Examflag>
<Bookmarkflag>N</Bookmarkflag>
<Chatflag>N</Chatflag>
<Discussflag>Y</Discussflag>
<Lessoncompletestatus>N</Lessoncompletestatus>
<Coursedesc>Customer Service Skills Introduction</Coursedesc>
<Switchvariablefield1>0</Switchvariablefield1>
<Cmailflag>N</Cmailflag>
<IMailflag>N</IMailflag>
<Imsflag>Y</Imsflag>
<Alternatecourse/>
<Collaborativetoolflag>0</Collaborativetoolflag>
<Chatlink/>
<Calendarlink/>
<VideoDuration>6:51</VideoDuration>
<Difficulty>Easy</Difficulty>
<PassingScore>80</PassingScore>
<MaxAttempts>100</MaxAttempts>
</Response>
后来我更改了我的 xml,然后<TotalQuestions>28</TotalQuestions>
<VideoID>8</VideoID>
在我的 xml 中添加了两个节点。现在在我的 responseString 中,我没有得到上面提到的两个节点。我无法找到任何替代方案。我试图清除我的浏览器缓存并清理我的构建,但我得到了相同的旧 xml,但缺少两个节点。此外,我试图更改字符串编码类型,但它没有用。对此有什么建议或替代方案会有很大帮助吗?