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 6711985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:12:23+00:00 2026-05-26T08:12:23+00:00

do you like puzzles to resolve? This is a big one! First, I made

  • 0

do you like puzzles to resolve? This is a big one!

First, I made a lot of researches for the solution, but, my situation is still very complicated.

Well, I have a XML that is validated in a complex XSD file, but, inside that XML I also have another complex type that is for the digital signature (xmlsignature).

My XSD is:

  <xsd:element name="EnviarLoteRpsEnvio">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="LoteRps" type="tcLoteRps"/>
        <xsd:element ref="dsig:Signature" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

The LoteRps (imagine a class like TPerson) is a complex type, and below the LoteRps I have my problem, the element dsig:Signature

To validate the LoteRps I have my XSD file (as described), but, to validate the dsig:Signature.

Well, what do I am doing?
A: I am doing a webservice that receives XML as parameter. For example:

ProcessLoteRps(XmlDocument loteRpsXml);

When I receive the Xml (that contais the elements LoteRps and Signature), I need validate the XML, to verify if the LoteRps and Signature are in the right sctruture. I don’t have problem when verifying the LoteRps structure, because I can add the schema, but, when I add the schema for Signature, then I get the error. The code to validate:

//function that returns the erros of the XML structure - if is wrong - in a list of string    
public static List<string> ValidaXMLComXSD(XmlDocument xmlTemp)
            {
                List <string> lista_erros = new List<string>();
                try
                {
                    // add the schemas...
                    xmlTemp.Schemas.Add("http://www.abrasf.org.br/ABRASF/arquivos/nfse.xsd", "Models\XSD\NFSE.xsd");
                    // HEY BRO, THE PROBLEM OCCURS HERE
                    xmlTemp.Schemas.Add("http://www.w3.org/2000/09/xmldsig#", HttpContext.Current.Server.MapPath("~/") + @"Models\XSD\xmldsig-core-schema20020212.xsd");
                }
                catch (Exception e)
                {
                    throw new Exception("Erro ao validar o XML: " + e.Message);
                }
            }

As we can see, I am adding 2 schemas:

  1. To validate the RPS (via XSD);
  2. To validate the Signature (via DTD).

If I do not add the schema for Signature, I get the following error:

The 'http://www.w3.org/2000/09/xmldsig#:Signature' element is not declared.

Ok, then, theoretically I have to add the Signature schema to validate as we can see below:

xmlTemp.Schemas.Add("http://www.w3.org/2000/09/xmldsig#", HttpContext.Current.Server.MapPath("~/") + @"Models\XSD\xmldsig-core-schema20020212.xsd");

But, when I add that schema, I get another (known) error:

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method.

Well, researching at google, i found a lot of links:

Problem validation a XML file with a local DTD file in C#

http://www.eggheadcafe.com/microsoft/Csharp/33292915/xml-prohibitdtd-error.aspx

I tried a lot of stuffs, but, still getting error..

Then I tried to invent:

public static List ValidaXMLComXSD(XmlDocument xmlTemp)
{

    List <string> lista_erros = new List<string>();

    try
    {
        #region Test
        XmlErrors xmlErros = new XmlErrors();

        XmlReaderSettings xsdSettings = new XmlReaderSettings();
        xsdSettings.ValidationType = ValidationType.Schema;
        xsdSettings.ValidationEventHandler += new ValidationEventHandler(xmlErros.XmlErrorsHandler);


        XmlReaderSettings dtdSettings = new XmlReaderSettings();
        dtdSettings.ValidationType = ValidationType.DTD;
        dtdSettings.ProhibitDtd = false;
        dtdSettings.ValidationEventHandler += new ValidationEventHandler(xmlErros.XmlErrorsHandler);


        xmlTemp.Schemas.Add(null, XmlReader.Create(NFSE_XSD_PATH, xsdSettings));
        // The error occurs below
        xmlTemp.Schemas.Add(null, XmlReader.Create(NFSE_XSD_SIG_PATH, dtdSettings));

And a new error appears:

An error has occurred while opening external DTD 'http://www.w3.org/2001/XMLSchema.dtd': The server committed a protocol violation. Section=ResponseStatusLine

Then, that broken my leggs…

I don’t know what to do… :s

Please, I need your help.

Best regards,
Dan

  • 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-26T08:12:24+00:00Added an answer on May 26, 2026 at 8:12 am

    You shouldn’t download the schema from the server every time your program runs. You should download it once and keep it on your hard drive.

    I think this will also take care of the “protocol violation” error.

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

Sidebar

Related Questions

This one has me puzzled. It seemed like an easy task, but the solution
This one puzzles me. I get an error about seek when I'm not even
In trying to resolve Facebook's Puzzle Hoppity Hop, http://www.facebook.com/careers/puzzles.php?puzzle_id=7 , I'm reading one integer
Like many others on this site I am considering a move to ASP.NET MVC
This is really looks like some magic is going on and I'm interested to
Not sure where to start on this one -- not sure if the problem
Like the title says, my code basically does this: set proxy, test proxy, do
It looks like we'll be adding CAPTCHA support to Stack Overflow. This is necessary
This is a thing that puzzles me. I know that when you use Euler
If I do like this in the python prompt: import platform platform.system() I get

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.