久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='1PEYN'></tfoot>
  1. <i id='1PEYN'><tr id='1PEYN'><dt id='1PEYN'><q id='1PEYN'><span id='1PEYN'><b id='1PEYN'><form id='1PEYN'><ins id='1PEYN'></ins><ul id='1PEYN'></ul><sub id='1PEYN'></sub></form><legend id='1PEYN'></legend><bdo id='1PEYN'><pre id='1PEYN'><center id='1PEYN'></center></pre></bdo></b><th id='1PEYN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1PEYN'><tfoot id='1PEYN'></tfoot><dl id='1PEYN'><fieldset id='1PEYN'></fieldset></dl></div>
      <bdo id='1PEYN'></bdo><ul id='1PEYN'></ul>
  2. <small id='1PEYN'></small><noframes id='1PEYN'>

    1. <legend id='1PEYN'><style id='1PEYN'><dir id='1PEYN'><q id='1PEYN'></q></dir></style></legend>

      未聲明 XML 簽名元素

      XML Signature element is not declared(未聲明 XML 簽名元素)

    2. <small id='VzfMs'></small><noframes id='VzfMs'>

      <legend id='VzfMs'><style id='VzfMs'><dir id='VzfMs'><q id='VzfMs'></q></dir></style></legend>

    3. <tfoot id='VzfMs'></tfoot>
          <tbody id='VzfMs'></tbody>

              • <bdo id='VzfMs'></bdo><ul id='VzfMs'></ul>
              • <i id='VzfMs'><tr id='VzfMs'><dt id='VzfMs'><q id='VzfMs'><span id='VzfMs'><b id='VzfMs'><form id='VzfMs'><ins id='VzfMs'></ins><ul id='VzfMs'></ul><sub id='VzfMs'></sub></form><legend id='VzfMs'></legend><bdo id='VzfMs'><pre id='VzfMs'><center id='VzfMs'></center></pre></bdo></b><th id='VzfMs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='VzfMs'><tfoot id='VzfMs'></tfoot><dl id='VzfMs'><fieldset id='VzfMs'></fieldset></dl></div>

                本文介紹了未聲明 XML 簽名元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我使用 Visual StudioXML 工具創建了 XSD.我使用以下 C# 代碼來驗證 XML 并遇到此錯誤.

                錯誤

                <塊引用>

                元素未聲明'

                即使我將 XSD 引用到本地文件,它也不起作用.我看到了同樣的錯誤.

                 <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212 file:///C:/Temp/xmldsig-core-schema.xsd"/>

                更新 #2

                即使我使用這種方法也沒有樂趣.

                 public static bool IsValidXml1(string xmlFilePath, string xsdFilePath, string namespaceName){XDocument xdoc = null;var settings = new XmlReaderSettings();settings.DtdProcessing = DtdProcessing.Ignore;settings.ProhibitDtd = false;嘗試{使用 (XmlReader xr = XmlReader.Create(xmlFilePath, settings)){xdoc = XDocument.Load(xr);var schemas = new XmlSchemaSet();schemas.Add(namespaceName, xsdFilePath);schemas.Add(@"http://www.w3.org/2000/09/xmldsig#", @"D:Tempxmldsig-core-schema.xsd");xdoc.Validate(模式,空);返回真;}}捕獲(XmlSchemaValidationException 前){//扔;}返回假;}

                解決方案

                如果您不想將任何內容更改為 xsd 或 xml - 請執行以下操作:

                1. (可選)從 w3 站點 并保存到本地磁盤.W3 站點非常慢,因為全球許多軟件不斷請求這些模式.如果您將直接使用該 xsd - 您通常會因超時而失敗.一些驗證工具已經在本地緩存了此類架構,但沒有 .NET 驗證器.

                2. 通過以下方式從 UPDATE 2 修改您的驗證方法:

                  public static bool IsValidXml1(string xmlFilePath, string xsdFilePath, string namespaceName){XDocument xdoc = null;var settings = new XmlReaderSettings();settings.DtdProcessing = DtdProcessing.Ignore;嘗試{使用 (XmlReader xr = XmlReader.Create(xmlFilePath, settings)){xdoc = XDocument.Load(xr);var schemas = new XmlSchemaSet();schemas.Add(namespaceName, xsdFilePath);使用 (var fs = File.OpenRead(@"D:Tempxmldsig-core-schema.xsd"))使用 (var reader = XmlReader.Create(fs, new XmlReaderSettings() {DtdProcessing = DtdProcessing.Ignore//重要})) {schemas.Add(@"http://www.w3.org/2000/09/xmldsig#", reader);}xdoc.Validate(模式,空);返回真;}}捕獲(XmlSchemaValidationException 前){//扔;}返回假;}

                您必須使用 XmlReader 而不是直接添加該架構,因為如果您直接添加(如在更新 2 中) - 它將無法解析 DTD 塊,因為當您添加 XmlSchemaXmlSchemaSet 使用 url(或文件路徑) - 它將使用 XmlReaderSettingsDtdProcessing = DtdProcessing.Prohibit 讀取該文件.我們需要將其更改為 DtdProcessing.IgnoreDtdProcessing.Parse.之后,您的驗證方法將適用于目標 xsd 和 xml 文件,無需任何更改(如果 xml 與 xsd 不匹配,則會正確失敗).

                I created XSD using Visual StudioXML Tools. And I use following C# code to validate XML and facing this error.

                Error

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

                So my question is how to fix it because in edit mode XML is valid 100%?

                Thank you!

                C#

                  private void buttonValidateXML_Click(object sender, EventArgs e)
                        {
                            try
                            {            
                                bool result = IsValidXml2(textBoxSignedXML.Text, textBoxXSDFile.Text, "");
                                rtbValidationResult.Text = result.ToString();
                            }
                            catch (Exception ex)
                            {
                                rtbValidationResult.Text = ex.Message;
                            }
                        }
                
                public static bool IsValidXml2(string xmlFilePath, string xsdFilePath, string namespaceName)
                        {
                            var xdoc = XDocument.Load(xmlFilePath);
                            var schemas = new XmlSchemaSet();
                            schemas.Add(namespaceName, xsdFilePath);
                
                            bool result = true;
                            xdoc.Validate(schemas, (sender, e) =>
                            {
                                result = false;
                            });
                
                            return result;
                        }
                

                XML

                <?xml version="1.0" encoding="utf-8"?>
                <Envelope version="1">
                  <Deposit>
                    <ClientId>1234567890123</ClientId>
                    <Account>0045678</Account>
                    <Currency>USD</Currency>
                    <Total>5000.00</Total>
                    <SignedDate>2016-02-15</SignedDate>     
                    <Cheques>
                      <Cheque>
                        <Images>
                          <Front>
                            SUkqAAgAAAAPAP4ABAABAAAAAAAAAAABBAABAAAAfQUAAAEBBAABAAAAWgIAAAIBAwABAAAAAQAA
                            AAMBAwABAAAABAAAAAYBAwABAAAAAAAAAA4BAgAhAAAA0AAAABEBBAABAAAAAAIAABIBAwABAAAA
                            AQAAABUBAwABAAAAAQAAABYBBAABAAAAWgIAABcBBAABAAAAvi8AABoBBQABAAAAAAEAABsBBQAB
                            EdF0fRG0R0YRdH2R2XzaI6OxRQAQAQA=
                          </Front>
                          <Back>
                            SUkqAAgAAAAOAP4ABAABAAAAAAAAAAABBAABAAAAgQUAAAEBBAABAAAAVAIAAAIBAwABAAAAAQAA
                            AAMBAwABAAAABAAAAAYBAwABAAAAAAAAABEBBAABAAAAAAEAABIBAwABAAAAAQAAABUBAwABAAAA
                            AQAAABYBBAABAAAAVAIAABcBBAABAAAAcggAABoBBQABAAAAwAAAABsBBQABAAAA0AAAACgBAwAB
                            AAAAAgAAAAAAAAAAAAAAAAAAAAAAyAAAAAEAAAAAAAAAAAAAAMgAAAABAAAAAAAAAAAAAAAAAAAA
                            AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//LZCdO1f7iRrKXTqt//pePx///9lNoL487Ajh
                            jFyzUrtwg+6gg9VmvCIWA42XMwziSUEEw7GoIcSUWZ3Y0oKmGR3LToGVC2LhkK6H4sorQNRUMLjH
                            LTGzlpv3RFCcH4NLB9hvLTmD8tMgOsG+WVaR5AweTcEWMMfaDQxDIx5NwVQx8OMPeGFHLSUlLcSS
                            1JtNV/9/rrffuO+h9bx////kfvABABAA
                          </Back>
                        </Images>
                        <MicrCodeCmc>123456789012345678901234567890</MicrCodeCmc>
                        <Amount>465.22</Amount>
                        <PaymentDate>2016-02-15</PaymentDate>
                        <EmissionDate>2016-02-15</EmissionDate>
                      </Cheque>
                      <Cheque>
                        <Images>
                          <Front>
                            SUkqAAgAAAAPAP4ABAABAAAAAAAAAAABBAABAAAAfQUAAAEBBAABAAAAWgIAAAIBAwABAAAAAQAA
                            AAMBAwABAAAABAAAAAYBAwABAAAAAAAAAA4BAgAhAAAA0AAAABEBBAABAAAAAAIAABIBAwABAAAA
                            AQAAABUBAwABAAAAAQAAABYBBAABAAAAWgIAABcBBAABAAAAvi8AABoBBQABAAAAAAEAABsBBQAB
                            EdF0fRG0R0YRdH2R2XzaI6OxRQAQAQA=
                          </Front>
                          <Back>
                            SUkqAAgAAAAOAP4ABAABAAAAAAAAAAABBAABAAAAgQUAAAEBBAABAAAAVAIAAAIBAwABAAAAAQAA
                            AAMBAwABAAAABAAAAAYBAwABAAAAAAAAABEBBAABAAAAAAEAABIBAwABAAAAAQAAABUBAwABAAAA
                            AQAAABYBBAABAAAAVAIAABcBBAABAAAAcggAABoBBQABAAAAwAAAABsBBQABAAAA0AAAACgBAwAB
                            AAAAAgAAAAAAAAAAAAAAAAAAAAAAyAAAAAEAAAAAAAAAAAAAAMgAAAABAAAAAAAAAAAAAAAAAAAA
                            AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//LZCdO1f7iRrKXTqt//pePx///9lNoL487Ajh
                            jFyzUrtwg+6gg9VmvCIWA42XMwziSUEEw7GoIcSUWZ3Y0oKmGR3LToGVC2LhkK6H4sorQNRUMLjH
                            LTGzlpv3RFCcH4NLB9hvLTmD8tMgOsG+WVaR5AweTcEWMMfaDQxDIx5NwVQx8OMPeGFHLSUlLcSS
                            1JtNV/9/rrffuO+h9bx////kfvABABAA
                          </Back>
                        </Images>
                        <MicrCodeCmc>123456789012345678901234567890</MicrCodeCmc>
                        <Amount>99999999999</Amount>
                        <PaymentDate>2016-02-15</PaymentDate>
                        <EmissionDate>2016-02-15</EmissionDate>
                      </Cheque>
                    </Cheques>
                  </Deposit>   
                  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
                    <SignedInfo>
                      <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
                      <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
                      <Reference URI="">
                        <Transforms>
                          <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                        </Transforms>
                        <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                        <DigestValue>TVO2Gssf5TUdXFYG/PrHDyqYFqs=</DigestValue>
                      </Reference>
                    </SignedInfo>
                    <SignatureValue>KwQInN03ywa0u0t4HedxgE1fOU7XYLQScKuQ6vdYoIZME5Hm5jpFeX2ORA2U+BO7JNjmFilTW05VntS3k98YCZhNXH9Iw/YEC1nw4JJLzygYbbCftkiY5v5+b494mQPryCtscwTtbziW6QilILSFDGmco2JopRfVe+qfdN/JyB1HXhUfApyNEsw/cJLj6aaz5ivN1sLFgAlikbwCNpF+mRnZY5u7/S8uT8WhEyK32EcatdjzKbP0PwnIlumhOpUMerWeLZ7neuJq6R/IuFgZ1Y5U6ppyuOjhtiHp4glC/uNUS/y7jMzG29thWBkEtSE9AcEt2IZ0HOEZE3kdFXufjA==</SignatureValue>
                  </Signature>
                </Envelope>
                

                XSD

                <?xml version="1.0" encoding="utf-8"?>
                <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
                           xmlns:tns="http://example.com/ct-required"
                           xmlns:xmime="http://www.w3.org/2005/05/xmlmime" >
                
                  <xs:import namespace="http://www.w3.org/2005/05/xmlmime"
                            schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
                
                    <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
                
                  <xs:simpleType name="PNGPictureType"
                          xmime:expectedContentTypes="image/png">
                    <xs:restriction base="xs:base64Binary"/>
                  </xs:simpleType>
                
                  <xs:simpleType name="Money">
                    <xs:restriction base="xs:decimal">
                      <xs:totalDigits value="13" />
                      <xs:fractionDigits value="2" />
                      <xs:minInclusive value="0.00" />
                      <xs:maxInclusive value="99999999999.99" />
                    </xs:restriction>
                  </xs:simpleType>
                
                  <xs:simpleType name="Currency">
                        <xs:annotation>
                            <xs:documentation>Currency Code: ISO 4217</xs:documentation>
                        </xs:annotation>
                        <xs:restriction base="xs:string">
                            <xs:enumeration value="USD" />
                            <xs:enumeration value="UYU" />
                            <xs:minLength value="3" />
                            <xs:maxLength value="3" />
                        </xs:restriction>
                    </xs:simpleType>
                
                  <xs:element name="Envelope">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element name="Deposit" minOccurs="1" maxOccurs="1">
                          <xs:complexType>
                            <xs:sequence>
                              <xs:element name="ClientId" type="xs:unsignedLong" />
                              <xs:element name="Account" type="xs:unsignedLong" />
                              <xs:element name="Currency" type="Currency" />
                              <xs:element name="Total" type="Money" />
                              <xs:element name="SignedDate" type="xs:date" />
                              <xs:element name="Cheques">
                                <xs:complexType>
                                  <xs:sequence>
                                    <xs:element maxOccurs="unbounded" name="Cheque">
                                      <xs:complexType>
                                        <xs:sequence>
                                          <xs:element name="Images">
                                            <xs:complexType>
                                              <xs:sequence>
                                                <xs:element name="Front" type="PNGPictureType" />
                                                <xs:element name="Back" type="PNGPictureType" />
                                              </xs:sequence>
                                            </xs:complexType>
                                          </xs:element>
                                          <xs:element name="MicrCodeCmc" type="xs:string" />
                                          <xs:element name="Amount" type="Money" />
                                          <xs:element name="PaymentDate" type="xs:date" />
                                          <xs:element name="EmissionDate" type="xs:date" />
                                        </xs:sequence>
                                      </xs:complexType>
                                    </xs:element>
                                  </xs:sequence>
                                </xs:complexType>
                              </xs:element>
                            </xs:sequence>
                          </xs:complexType>
                        </xs:element>
                        <xs:element xmlns:q1="http://www.w3.org/2000/09/xmldsig#" ref="q1:Signature" />
                      </xs:sequence>
                      <xs:attribute name="version" type="xs:unsignedByte" use="required" />
                    </xs:complexType>
                  </xs:element>
                </xs:schema>
                

                UPDATE #1

                I have tried different approaches but no joy.

                And even if I reference XSD to local file it does not work. I see the same error.

                 <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="http://www.w3.org/TR/2002/REC-xmldsig-core-20020212 file:///C:/Temp/xmldsig-core-schema.xsd"/>
                

                UPDATE #2

                Even I use this approach no joy.

                 public static bool IsValidXml1(string xmlFilePath, string xsdFilePath, string namespaceName)
                        {
                            XDocument xdoc = null;
                            var settings = new XmlReaderSettings();
                            settings.DtdProcessing = DtdProcessing.Ignore;
                            settings.ProhibitDtd = false;
                
                            try
                            {
                                using (XmlReader xr = XmlReader.Create(xmlFilePath, settings))
                                {
                                    xdoc = XDocument.Load(xr);
                                    var schemas = new XmlSchemaSet();
                                    schemas.Add(namespaceName, xsdFilePath);
                                    schemas.Add(@"http://www.w3.org/2000/09/xmldsig#", @"D:Tempxmldsig-core-schema.xsd");
                                    xdoc.Validate(schemas, null);
                
                                    return true;
                                }                
                            }
                            catch (XmlSchemaValidationException ex)
                            {
                                // throw;
                            }
                
                            return false;
                        }
                

                解決方案

                If you don't want to change anything to xsd or xml - do the following:

                1. (optional) Download xsd from w3 site and save to local disk. W3 site is VERY slow because a lot of software worldwide constantly request those schemas. If you will use that xsd directly - you will often fail by timeout. Some validation tools already have such schemas cached locally, but not .NET validator.

                2. Modify your validation method from UPDATE 2 the following way:

                  public static bool IsValidXml1(string xmlFilePath, string xsdFilePath, string namespaceName)
                  {
                      XDocument xdoc = null;
                      var settings = new XmlReaderSettings();
                      settings.DtdProcessing = DtdProcessing.Ignore;
                  
                      try
                      {
                          using (XmlReader xr = XmlReader.Create(xmlFilePath, settings))
                          {
                              xdoc = XDocument.Load(xr);
                              var schemas = new XmlSchemaSet();                    
                              schemas.Add(namespaceName, xsdFilePath);                   
                              using (var fs = File.OpenRead(@"D:Tempxmldsig-core-schema.xsd")) 
                              using (var reader = XmlReader.Create(fs, new XmlReaderSettings() {
                                  DtdProcessing = DtdProcessing.Ignore // important
                              })) {
                                  schemas.Add(@"http://www.w3.org/2000/09/xmldsig#", reader);
                              }
                  
                              xdoc.Validate(schemas, null);
                  
                              return true;
                          }
                      }
                      catch (XmlSchemaValidationException ex)
                      {
                          // throw;
                      }
                  
                      return false;
                  }
                  

                You have to add that schema using XmlReader and not directly, because if you add directly (like in your update 2) - it will fail to parse DTD block, because when you add XmlSchema to XmlSchemaSet using url (or file path) - it will read that file using XmlReaderSettings with DtdProcessing = DtdProcessing.Prohibit. We need to change that to DtdProcessing.Ignore or DtdProcessing.Parse. After that your validation method will work fine for target xsd and xml file, without any changes (and will correctly fail in case xml does not match xsd).

                這篇關于未聲明 XML 簽名元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
                <legend id='x8RcN'><style id='x8RcN'><dir id='x8RcN'><q id='x8RcN'></q></dir></style></legend>

                        <tbody id='x8RcN'></tbody>

                      • <bdo id='x8RcN'></bdo><ul id='x8RcN'></ul>

                        <small id='x8RcN'></small><noframes id='x8RcN'>

                          <i id='x8RcN'><tr id='x8RcN'><dt id='x8RcN'><q id='x8RcN'><span id='x8RcN'><b id='x8RcN'><form id='x8RcN'><ins id='x8RcN'></ins><ul id='x8RcN'></ul><sub id='x8RcN'></sub></form><legend id='x8RcN'></legend><bdo id='x8RcN'><pre id='x8RcN'><center id='x8RcN'></center></pre></bdo></b><th id='x8RcN'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='x8RcN'><tfoot id='x8RcN'></tfoot><dl id='x8RcN'><fieldset id='x8RcN'></fieldset></dl></div>
                          <tfoot id='x8RcN'></tfoot>
                        • 主站蜘蛛池模板: 久久久久久999 | 人人九九精 | 国产精品国产 | 91亚洲国产成人久久精品网站 | 国产99久久久国产精品 | 欧美亚洲国产一区二区三区 | 中文字幕一区二区三区四区 | 国产精品永久久久久 | 精品亚洲一区二区三区 | 久久精品综合 | 日韩欧美成人精品 | 日日摸天天添天天添破 | 欧美精品一区二区蜜桃 | 欧美日本免费 | 午夜影院中文字幕 | 日韩第1页| 欧美激情一区二区三区 | 久久影音先锋 | 波多野结衣中文字幕一区二区三区 | 91小视频在线 | 操网站| 一区中文字幕 | 精品在线免费观看视频 | 日本a级大片 | 黄色毛片免费视频 | 日韩一区二区在线观看 | 视频一区二区在线观看 | 久久91 | 亚洲网站在线观看 | 精品久久九九 | www.精品国产| 亚洲一区二区三区观看 | 亚洲成av人片在线观看 | 综合久久99 | 少妇性l交大片免费一 | 欧美一二三 | 亚洲91精品 | 精品亚洲一区二区三区 | 成人小视频在线观看 | 国产精品精品久久久久久 | 色婷婷av一区二区三区软件 |