XmlReader.Create not working when credentials needed

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all;
I am trying to open an XML file that is an https://... which requires a username/password. My code is:
<div style="color:Black;background-color:White; <pre>
XmlReaderSettings settings = <span style="color:Blue; new XmlReaderSettings {ProhibitDtd = <span style="color:Blue; false};
settings.ValidationType = ValidationType.Schema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ReportValidationWarnings;

XmlUrlResolver resolver = <span style="color:Blue; new XmlUrlResolver
{ Credentials = <span style="color:Blue; new NetworkCredential(user, password, domain)};
xmlSettings.XmlResolver = resolver;

<span style="color:Blue; return XmlReader.Create(filename, xmlSettings);
[/code]
And I am getting the exception:
<pre>System.Net.WebException occurred
Message=Unable to connect to the remote server
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at Kailua.net.windward.utils.xml.XmlZipResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) in C:srcAkamaiKailuanetwindwardutilsxmlXmlZipResolver.cs:line 49
InnerException: System.Net.Sockets.SocketException
Message=No connection could be made because the target machine actively refused it 127.0.0.1:8888
Source=System
ErrorCode=10061
NativeErrorCode=10061
StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
InnerException:
[/code]
Any ideas? If I pass the same url used in the code to my browser, it prompts me for my login and then displays the file.
thanks - dave <hr class="sig Very funny video - http://blogs.windwardreports.com/davidt/2010/02/reporting-as-a-metaphor.html
Whats your Metaphor?

View the full article
 
Back
Top