开发者

How to use System.Net.WebClient() to download XML from a webservice with correctly encoded tags?

I'm using System.Net.WebClient().DownloadFile() to download the response of a webservice to a file. The response is rather large, so I don't use direct SOAP calls which would return a single string, eating up too much memory. The response of the webservice is XML and what I get back is something like

<?xml version="1.0" encoding="utf-8?>
<string xmlns="MyAPI>
&lt;object name="First object"&gt;
...

So the issue is that the whole response gets wrapped into a "string" attribute and the real XML conten开发者_开发问答t gets encoded. Without re-reading the whole saved file and converting everything back, how can I get the response in its original and correct format?


I don't know why you believe that a web service call would take up too much memory. Did you try WCF?

Your problem is that you are calling the service the wrong way. You are no doubt using a GET HTTP request.

If you insist on not using a Service Reference, then I recommend you use WebRequest, and read the result through the GetResultStream() method. You could even process the result as XML by passing that stream into XmlReader.Create(Stream), which will return an XmlReader object that can be used to read the data without reading it all into memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜