Proxy authentication when doing xsl transform

C

Chris Dunaway

I am processing cXml orders and the xml begins with the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.017/
cXML.dtd">

I am attempting to use the following code to transform the xml:

XslCompiledTransform transform = new XslCompiledTransform();
Stream resultStream = new MemoryStream();

XmlReader xslRdr = XmlReader.Create(new StringReader(xslSheet));

transform.Load(xslRdr);

XmlReaderSettings xRdrSettings = new XmlReaderSettings();
xRdrSettings.ProhibitDtd = false;
xRdrSettings.ValidationType = ValidationType.DTD;

XmlReader xmlRdr = XmlReader.Create(cxmlFilename, xRdrSettings);
transform.Transform(xmlRdr, null, resultStream);

My problem is that in my organization, my test machine cannot access
the url in the DOCTYPE without proxy authentication. I get this
exception when running the code:

"An error has occurred while opening external DTD 'http://xml.cxml.org/
schemas/cXML/1.2.017/cXML.dtd': The remote server returned an error:
(407) Proxy Authentication Required."

Can anyone point me to some examples of how to apply the proxy
authentication?

I attempted to create an XmlUriResolver with the proper proxy
credentials, and passed that into the XmlReaderSettings.XmlResolver
property, but that made no difference. I must be missing something
easy.

Any help would be appreciated.

Thanks,

Chris
 
C

Chris Dunaway

I too would have looked at the XmlUrlResolver route; however, another
option might be to well .Net about your proxy - then *all* code should
be able to find it:
You can do this either in your local app.config/web.config, or at the
machine level if you have a lot of apps

http://support.microsoft.com/default.aspx?scid=kb;en-us;318140

Marc

Thanks for the response. But really, I didn't want to validate the
DTD in the first place. I needed the proxy authentication because of
the DTD.

I resolved the issue by setting the XmlResolver property of the
XmlReaderSettings object to null.

Thanks again,

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top