Answered by:
Accessing xml from another site

Question
-
I am trying to access another website and download xml. The clientaccesspolicy.xml file is in place. When the returned xml is small in size I have no problems. When the size is large I get an exception:
System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
It is just a website that returns xml - it is not a webservice, like WCF etc.
Am I missing some settings?
Thursday, August 20, 2009 1:22 PM
Answers
-
The best way to do this is by using isolated storage(you can increase the size of your data) and syndicated feeds(which use atom or rss
the syndicated feeds have a client access policy themselves-john papa has a chapter on this http://books.google.com/books?id=o92WkIjDpAUC&pg=PA1&dq=silverlight+2#
http://msdn.microsoft.com/en-us/magazine/dd419660.aspx
http://silverlight.net/learn/learnvideo.aspx?video=65672
http://msdn.microsoft.com/en-us/library/bdts8hk0(VS.95).aspx
http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Isolated-Storage/
Saturday, August 22, 2009 10:55 AM
All replies
-
How are you downloading the XML? WebClient? It would be helpful to see the code, otherwise it is pretty hard to give you advice.
Thursday, August 20, 2009 1:26 PM -
Yes, I am using WebClient. In
Uri url = new Uri(escString); WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);client.DownloadStringAsync(url);
Then:
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
{
stream = new StringReader(e.Result);reader =
XmlReader.Create(stream);xd =
XDocument.Load(reader);}
}
Thursday, August 20, 2009 1:56 PM -
And when the xml is large, you can open it in the browser with no problems?
I'm assuming you get the exception prior to the download complete event firing?
Thursday, August 20, 2009 2:00 PM -
When the returned XML is large, I can open it in IE. I get the error in client_DownloadStringCompleted event handler., not before
At
if (e.Error == null) The e.message and error info shows the "Not Found" error - when I download a large set of xml
Thursday, August 20, 2009 2:27 PM -
Hmm.. Seems like you're doing everything correctly. I'd suggest giving the WebRequest a try instead of the WebClient to see if that fixes your issue. The WebClient is pretty limited and might have a max size limitation.
Thursday, August 20, 2009 2:38 PM -
WebRequest is also giving the same error. For WCF and webservcies there seems to be a size limitation, which you can take care off using seetings in the Web.config file. Since the URLs I am accessing are not coming from a service is there any other location that this size can be set?
Thursday, August 20, 2009 3:39 PM -
here is an article on getting xml data http://jobijoy.blogspot.com/2009/03/different-ways-to-access-xml-data-in.html
you can use mtom encoding in silverlight 3
also use a feed that suppports atom or rss.
Thursday, August 20, 2009 11:11 PM -
if you are looking for an architecture use silverlight wcf sockets http://weblogs.asp.net/dwahlin/archive/2008/04/10/pushing-data-to-a-silverlight-client-with-sockets-part-i.aspx
and here http://silverlight.net/forums/t/113642.aspx mtom encoding using silverlight 3
Thursday, August 20, 2009 11:26 PM -
I am not planning on using wcf sockets. I would like to use either webclient or HttpWebRequest to do a simple download of XML from another site. I have the security files on that site and can download smaller files. It is only the bigger file sthat run into a problem.
Is there anyway to see what the problem actually is? Is the Notfound error masking some other error? Because the large xml from the external site loads on IE but does not load in Silverlight.
Friday, August 21, 2009 3:58 PM -
The best way to do this is by using isolated storage(you can increase the size of your data) and syndicated feeds(which use atom or rss
the syndicated feeds have a client access policy themselves-john papa has a chapter on this http://books.google.com/books?id=o92WkIjDpAUC&pg=PA1&dq=silverlight+2#
http://msdn.microsoft.com/en-us/magazine/dd419660.aspx
http://silverlight.net/learn/learnvideo.aspx?video=65672
http://msdn.microsoft.com/en-us/library/bdts8hk0(VS.95).aspx
http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Isolated-Storage/
Saturday, August 22, 2009 10:55 AM -
to answer your other question yes you can check on this: you must use silverlight 3
here is the article that should help you fault strategies in silverlight 3
http://msdn.microsoft.com/en-us/magazine/ee294456.aspx
http://weblogs.asp.net/pglavich/archive/2009/07/14/silverlight-3-and-wcf-faults.aspx
http://dotnetslackers.com/Silverlight/re-223390_Silverlight_3_and_WCF_Faults.aspx
Saturday, August 22, 2009 11:02 AM -
you can use a wcf restful application using twitter that can return xml atom or json.
Please remember I am trying to help you.....However it is really up to you how you decide in what direction you want to go.....
Anyway good luck with your project.....
Saturday, August 22, 2009 11:53 AM -
Thanks for all your suggestions - Gave me a better understanding of what's going on. I think I have clue as to what's happening. I am using a sniffer to see exactly what's going on. It looks like when the large xml is returned, it is also returning some extra characters at the beginning of the document. This could be causing the problem. IE seems to handle these extra characters.The Service provider is yet to fix it - I will be able to verify if this is the case on Monday. Anyway it would be nice if WebRequest would return a more comprehensive error message about what is really happening.Saturday, August 22, 2009 12:16 PM
-
I am not sure what is happening I came upon this but I am not sure it will help you
http://www.capprime.com/software_development_weblog/CategoryView,category,WCF.aspx
http://silverlight.net/learn/learnvideo.aspx?video=66718 I also found two screencasts by using isolated storage
http://silverlight.net/learn/learnvideo.aspx?video=66680
Remember you use isolated storage to increase the data in a syndicated forum
Anyway good luck in your project......
Saturday, August 22, 2009 3:00 PM -
Hello CACUser,
Are you using SL3? If so, can you try changing to the client browser stack (http://msdn.microsoft.com/en-us/library/system.net.browser.webrequestcreator.clienthttp(VS.95).aspx) to see if you get a better error message for this scenario?
Tuesday, August 25, 2009 1:26 PM