I currently have a simple WCF service running with one get request which returns XML, http://a446062738bb4f0aa2d8fd975aac602f.cloudapp.net/Service1.svc/GetALLPictures/10... Im trying to use [NSString stringWithURL:] to populate the string with the XML content, however this is not working, ive tried using Unicode and UTF8 encoding to get the string and nothing, I have set the crossclient.xml on the server and i have consumed the service in a similar way in a silverlight application. (I have also tried all of the above using NSURLCOnnection and a NSURLRequest)
Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You mean +stringWithContentsOfURL:
? I'm not seeing any trouble with this:
NSString *xml = [NSString stringWithContentsOfURL:
[NSURL URLWithString:
@"http://a446062738bb4f0aa2d8fd975aac602f.cloudapp.net/Service1.svc/GetALLPictures/10"]];
It's returning this:
<GetAllPicturesResponse xmlns="http://tempuri.org/">
<GetAllPicturesResult
xmlns:a="http://schemas.datacontract.org/2004/07/TestCloudService_WebRole"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Coordinate><a:latitude>0</a:latitude><a:longitude>0</a:longitude>
</a:Coordinate><a:Coordinate><a:latitude>-50</a:latitude>
<a:longitude>-80</a:longitude></a:Coordinate></GetAllPicturesResult>
</GetAllPicturesResponse>
You'll want to use NSURLConnection
unless you're doing this on a background thread, but it seems fine.