System.Net.WebException: The remote server returned an error: (500)
Internal Server Error. at System.Net.HttpWebRequest.GetResponse() at
umbraco.library.GetXmlDocumentByUrl(String Url)
Things I have
tried:
I have ran several rss feeds through the xslt,
without any problems. They read and are rendered correctly.
I can view the feed in several rss
readers.
I have saved the feed as an xml document and can
read that document through this xslt as a local document.
thanks, this is my first post on the new forum. I will take some time to figure out the karma thing. So I am happy that I guessed right about the header information, but I am even happier that you knew how to do it.
Consuming and RSS Feed and the 500 Error
I am trying to consume the following rss feed:
http://www.youversion.com/reading-plans/life-journal-reading-plan/rss
But I receive the following error:
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse() at umbraco.library.GetXmlDocumentByUrl(String Url)
Things I have tried:
xslt:
xml:
Assuming that I am doing things correctly, I think "YouVersion" is blocking requests that do not come from a browser.
I really hope that I am not doing things correctly.
What do you think?
See if this helps:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:wm="urn:writemedia-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets "> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:param name="currentPage"/> <xsl:variable name="max"> <xsl:choose> <xsl:when test="/macro/max != ''"> <xsl:value-of select="/macro/max" /> </xsl:when> <xsl:otherwise>5</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- start writing XSLT --> <xsl:template match="/"> <xsl:variable name="xmlcontent" select="wm:getRSS()" /> <ul style="list-style:none;"> <xsl:apply-templates select="$xmlcontent/rss/channel/item" /> </ul> </xsl:template> <xsl:template match="item"> <xsl:if test="position() < number($max)"> <li> <h3> <a href="{link}" target="_blank"> <xsl:value-of select="substring(pubDate,1,16)"/> - <xsl:value-of select="title"/> </a> </h3> </li> </xsl:if> </xsl:template> <msxsl:script language="C#" implements-prefix="wm"> <![CDATA[ public System.Xml.XmlDocument getRSS() { try { System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://www.localendar.com/public/cardiffbrass?style=D4"); request.Headers["Accept-Encoding"] = "gzip"; request.Headers["Accept-Language"] = "en-us"; request.ContentType = "application/x-www-form-urlencoded"; request.UserAgent = "Mozilla/4.0+"; request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; request.AutomaticDecompression = System.Net.DecompressionMethods.GZip; using (System.Net.WebResponse response = request.GetResponse()) { using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream())) { System.Xml.XmlDocument MyRssDocument = new System.Xml.XmlDocument(); MyRssDocument.LoadXml(reader.ReadToEnd()); return MyRssDocument; } } } catch (System.Net.WebException ex) { throw new Exception(ex.Message); } } ]]> </msxsl:script> </xsl:stylesheet>
Hi Skycro
I think you should use the XSLT extension from the umbraco library called "GetXmlDocumentByUrl" so your variable will look like this:
<xsl:variable name="url" select="umbraco.library:GetXmlDocumentByUrl('http://www.youversion.com/reading-plans/life-journal-reading-plan/rss')" />
/Jan
mike_h,
thanks, this is my first post on the new forum. I will take some time to figure out the karma thing. So I am happy that I guessed right about the header information, but I am even happier that you knew how to do it.
skycro
is working on a reply...