Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 756555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:15:30+00:00 2026-05-14T15:15:30+00:00

I have looked at many examples for validating an XML file against a DTD,

  • 0

I have looked at many examples for validating an XML file against a DTD, but have not found one that allows me to use a proxy. I have a cXml file as follows (abbreviated for display) which I wish to validate:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.018/InvoiceDetail.dtd">
<cXML payloadID="123456" timestamp="2009-12-10T10:05:30-06:00">
    <!-- content snipped -->
</cXML>

I am trying to create a simple C# program to validate the xml against the DTD. I have tried code such as the following but cannot figure out how to get it to use a proxy:

private static bool isValid = false;

static void Main(string[] args)
{
   try
   {
     XmlTextReader r = new XmlTextReader(args[0]);
     XmlReaderSettings settings = new XmlReaderSettings();

     XmlDocument doc = new XmlDocument();

     settings.ProhibitDtd = false;
     settings.ValidationType = ValidationType.DTD;
     settings.ValidationEventHandler +=  new ValidationEventHandler(v_ValidationEventHandler);

     XmlReader validator = XmlReader.Create(r, settings);

     while (validator.Read()) ;
     validator.Close();

     // Check whether the document is valid or invalid.
     if (isValid)
         Console.WriteLine("Document is valid");
     else
         Console.WriteLine("Document is invalid");
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.ToString());
   }
}

static void v_ValidationEventHandler(object sender, ValidationEventArgs e)
{
    isValid = false;
    Console.WriteLine("Validation event\n" + e.Message);
}

The exception I receive is

System.Net.WebException: The remote server returned an error: (407) Proxy Authentication Required.

which occurs on the line while (validator.Read()) ;

I know I can validate against a DTD locally, but I don’t want to change the xml DOCTYPE since that is what the final form needs to be (this app is solely for diagnostic purposes). For more information about the cXML spec, you can go to cxml.org.

I appreciate any assistance.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:15:30+00:00Added an answer on May 14, 2026 at 3:15 pm

    It’s been a while since your question, so sorry if it’s a bit late!

    Here’s what seems to be the approved way to do it:

    1 – Create your very own proxy assembly:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.Configuration;
    
    namespace ProxyAssembly
    {
        public class MyProxy:IWebProxy
        {
    
    
    #region IWebProxy Members
    
        ICredentials  IWebProxy.Credentials
        {
            get 
            { 
                return new NetworkCredential(ConfigurationSettings.AppSettings["googleProxyUser"],ConfigurationSettings.AppSettings["googleProxyPassword"],ConfigurationSettings.AppSettings["googleProxyDomain"]); 
            }
            set { }
    
        }
    
        public Uri  GetProxy(Uri destination)
        {
            return new Uri(ConfigurationSettings.AppSettings["googleProxyUrl"]);
        }
    
        public bool  IsBypassed(Uri host)
        {
            return Convert.ToBoolean(ConfigurationSettings.AppSettings["bypassProxy"]);
        }
    
    #endregion
    }
    }
    

    2 – Put the needed keys into your web.config:

       <add key="googleProxyUrl"  value="http://proxy.that.com:8080"/>
        <add key="googleProxyUser"  value="service"/>
        <add key="googleProxyPassword"  value="BadDay"/>
        <add key="googleProxyDomain"  value="corporation"/>
        <add key="bypassProxy"  value="false"/>
    

    3 – Put in a defaultProxy section into your web.config

    <configuration>        
        <system.net>
            <defaultProxy>
                <module type="ProxyAssembly.MyProxy, ProxyAssembly"/>
            </defaultProxy>
        </system.net>    
    </configuration>
    

    Now ALL requests from your application will go through the proxy. That’s ALL requests – ie I don’t think that you can select to use this programatically, every resource request will try to go through the proxy! eg: validating xml using dtd docs, webservice calls, etc.

    Cheers,
    Lance

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked on FaceBook Developer page and found that it's possible to create
I have looked over the Repository pattern and I recognized some ideas that I
I have looked at the Suggested related questions but none of them are what
I have looked at the SQL Server 2008 feature comparison matrix and it lists
I have looked at NHibernate and EntitySpaces and they both seem to work differently.
I have looked around on the Internet trying to answer this question. It seems
I have looked all of the place for this and I can't seem to
I've used jdom in the past, and have looked briefly at XOM and DOM4j
Do you plan on using Factor ? Have you looked at it? Checked it
I have some accesses from 192.168.0.71 on my apache logs. I looked up this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.