HighTechTalks DotNet Forums  

Download XML: The underlying connection was closed: Unable to connect to the remote server.

Dotnet XML microsoft.public.dotnet.xml


Discuss Download XML: The underlying connection was closed: Unable to connect to the remote server. in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Simon
 
Posts: n/a

Default Download XML: The underlying connection was closed: Unable to connect to the remote server. - 12-31-2007 , 11:26 AM






Hi

We are trying to download an XML document from the internet and are getting
the error:

The underlying connection was closed: Unable to connect to the remote
server.

We are not behind a proxy server and have no desktop firewall / antivirus
blocking the connection.

When i add a web reference to my project i get the error:

The document at the url
http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis OR henman was not
recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'WSDL Document' is 'There is an error in XML document (3,
3).'.
- <rss xmlns=''> was not expected.
- Report from 'DISCO Document' is 'Discovery document at the URL
http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis OR henman could not
be found.'.
- The document format is not recognized.
- Report from 'XML Schema' is 'Expected Schema root. Make sure that the root
element is <schema> and the namespace is 'http://www.w3.org/2001/XMLSchema'
for an XSD schema or 'urn:schemas-microsoft-com:xml-data' for an XDR schema.
An error occurred at , (3, 3).'.


I have tried many types of web request in .net and the same problem occurs,
my code is currently:

Private Sub getxm()

' Retrieve XML document

Dim reader As XmlTextReader = New
XmlTextReader("http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis%20OR%20henman#")

' Skip non-significant whitespace

reader.WhitespaceHandling = WhitespaceHandling.Significant

' Read nodes one at a time

While reader.Read()

' Print out info on node

Console.WriteLine("{0}: {1}", reader.NodeType.ToString(), reader.Name)

End While

End Sub


And a sample of the XML is below:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet title="XSL_formatting" type="text/xsl" href="/nolsol.xsl"
?>
<rss version="2.0">
<channel>
<ttl>15</ttl>
<title>BBC News and Sport Search: tennis or henman</title>
<link>http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis+or+henman</link>
<description>BBC News and Sport Search: tennis or henman</description>
<language>en-gb</language>
<lastBuildDate>Mon, 31 Dec 2007 17:24:12 GMT</lastBuildDate>

<item>
<title>One woman's mission of the heart</title>
<link>http://news.bbc.co.uk/go/rss/news/int/search/news%2Bsport/tennis+or+henman/-/2/hi/uk_news/7164808.stm</link>
<guid
isPermaLink="false">http://news.bbc.co.uk/2/hi/uk_news/7164808.stm</guid>
<pubDate>Sun, 30 Dec 2007 15:00:17 GMT</pubDate>
<description>The head of a cardiac awareness charity explains why it
advocates a screening policy for people from all backgrounds, not just
sport.</description>
</item>

<item>
<title>Masters Tennis photos</title>
<link>http://news.bbc.co.uk/go/rss/news/int/search/news%2Bsport/tennis+or+henman/-/sport2/hi/tennis/7128537.stm</link>
<guid
isPermaLink="false">http://news.bbc.co.uk/sport2/hi/tennis/7128537.stm</guid>
<pubDate>Sun, 09 Dec 2007 17:11:02 GMT</pubDate>
<description>Pictures of the Masters Tennis at the Royal Albert
Hall</description>
</item>

<item>
<title>Bogdanovic 'handed golden chance'</title>
<link>http://news.bbc.co.uk/go/rss/news/int/search/news%2Bsport/tennis+or+henman/-/sport2/hi/tennis/7128277.stm</link>
<guid
isPermaLink="false">http://news.bbc.co.uk/sport2/hi/tennis/7128277.stm</guid>
<pubDate>Wed, 05 Dec 2007 10:41:46 GMT</pubDate>
<description>Tim Henman urges Alex Bogdanovic to take full advantage
of Brad Gilbert's coaching.</description>
</item>

</channel>
</rss>



Reply With Quote
  #2  
Old   
Martin Honnen
 
Posts: n/a

Default Re: Download XML: The underlying connection was closed: Unable toconnect to the remote server. - 12-31-2007 , 11:50 AM






Simon wrote:
Quote:
Hi

We are trying to download an XML document from the internet and are getting
the error:

The underlying connection was closed: Unable to connect to the remote
server.

We are not behind a proxy server and have no desktop firewall / antivirus
blocking the connection.

When i add a web reference to my project i get the error:

The document at the url
http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis OR henman was not
recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'WSDL Document' is 'There is an error in XML document (3,
3).'.
- <rss xmlns=''> was not expected.
- Report from 'DISCO Document' is 'Discovery document at the URL
http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis OR henman could not
be found.'.
- The document format is not recognized.
- Report from 'XML Schema' is 'Expected Schema root. Make sure that the root
element is <schema> and the namespace is 'http://www.w3.org/2001/XMLSchema'
for an XSD schema or 'urn:schemas-microsoft-com:xml-data' for an XDR schema.
An error occurred at , (3, 3).'.
That document is an RSS feed, it does not make sense to add a web
reference to it, that makes sense for WSDL document or schema documents
but not for RSS feeds.

Quote:
I have tried many types of web request in .net and the same problem occurs,
my code is currently:

Private Sub getxm()

' Retrieve XML document

Dim reader As XmlTextReader = New
XmlTextReader("http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis%20OR%20henman#")
Are you using .NET 1.x or why do you use XmlTextReader? With .NET 2.0 or
later the preferred way to create an XmlReader is with XmlReader.Create e.g.

using (XmlReader reader =
XmlReader.Create(@"http://newsapi.bbc.co.uk/feeds/search/news+sport/tennis%20OR%20henman#"))
{
while (reader.Read())
{
Console.WriteLine(reader.NodeType);
}
}

That works fine here for me with .NET 2.0, I do not get the error.

The error is at the network level anyway so I am not sure how to fix it
at the XML API level.
Are you able to read other feeds from the web using your code?




--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.