Click here to Skip to main content
15,435,841 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When Deserialize this XML in Visual Studio I got an error.
I do not know where the error could be, this is an "official" received XML


VB
Dim mySigedis As New BeMaangifte.Sigedis_odse.SecondPillarPensionODSEDeclarationsResponseFile
Dim x As New System.Xml.Serialization.XmlSerializer(mySigedis.GetType)
 mySigedis = x.Deserialize(objStreamReader)


Error on line 2

Any suggestions ?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<db2p-declarations-odse:SecondPillarPensionODSEDeclarationsResponseFile 
xmlns:db2p-declarations-odse="http://www.sigedis.be/db2p/declarations/odse/v1" 
xmlns:db2p-declarations-common="http://www.sigedis.be/db2p/declarations/common/v1" 
xmlns:person="http://kszbcss.fgov.be/types/DB2P/Common/Identification/Person/v3" 
xmlns:common="http://kszbcss.fgov.be/types/DB2P/Common/v3" 
xmlns:common-cbss="http://kszbcss.fgov.be/types/DB2P/Common/Internal/v3" 
xmlns:odse-cbss-sigedis="http://www.sigedis.be/db2p/declarations/odse/cbss-sigedis/v1">
     <db2p-declarations-odse:InformationCustomer>
          <common:Ticket>038041ZCYAB5Z</common:Ticket>
          <common:TimestampSent>2021-07-29T11:30:28.278+02:00</common:TimestampSent>
          <common:CustomerIdentification>
               <common:Sector>77</common:Sector>
               <common:Institution>1</common:Institution>
          </common:CustomerIdentification>
     </db2p-declarations-odse:InformationCustomer>
     <db2p-declarations-odse:InformationCBSS>
          <common:TicketCBSS>634067D20D5545DCAC72756D7595E4BD</common:TicketCBSS>
          <common:TimestampReceive>2021-07-29T11:30:28.278+02:00</common:TimestampReceive>
          <common:TimestampReply>2021-07-29T11:30:38.851+02:00</common:TimestampReply>
     </db2p-declarations-odse:InformationCBSS>
     <db2p-declarations-odse:AdministrativeData>
          <db2p-declarations-common:DeclarationFileId>2d695350-6601-462c-9d6f-6052ea987570</db2p-declarations-common:DeclarationFileId>
          <db2p-declarations-common:Recipient>0860363769</db2p-declarations-common:Recipient>
          <db2p-declarations-common:CreationMoment>2021-07-29T10:52:44+02:00</db2p-declarations-common:CreationMoment>
          <db2p-declarations-common:Environment>DB2P</db2p-declarations-common:Environment>
     </db2p-declarations-odse:AdministrativeData>
     <db2p-declarations-odse:Status>
          <common:Value>VALIDATION_ERROR</common:Value>
          <common:Code>DB2P0001</common:Code>
          <common:Description>XSD validation failed</common:Description>
          <common:Information>cvc-elt.1: Cannot find the declaration of element 'q1:SecondPillarPensionODSEDeclarationsFile'.</common:Information>
     </db2p-declarations-odse:Status>
</db2p-declarations-odse:SecondPillarPensionODSEDeclarationsResponseFile>


What I have tried:

I have tried changing this, but it does not help

<db2p-declarations-odse:SecondPillarPensionODSEDeclarationsResponseFile 
xmlns:db2p-declarations-odse="http://www.sigedis.be/db2p/declarations/odse/v1" 
xmlns:db2p-declarations-common="http://www.sigedis.be/db2p/declarations/common/v1" 
xmlns:person="http://kszbcss.fgov.be/types/DB2P/Common/Identification/Person/v3" 
xmlns:common="http://kszbcss.fgov.be/types/DB2P/Common/v3" 
xmlns:common-cbss="http://kszbcss.fgov.be/types/DB2P/Common/Internal/v3" 
xmlns:odse-cbss-sigedis="http://www.sigedis.be/db2p/declarations/odse/cbss-sigedis/v1">
Posted
Updated 29-Jul-21 4:06am
Comments
mathieudesmet2 29-Jul-21 9:23am     CRLF
this is the link to the XSD schema used https://www.db2p.be/nl/resources/247a5f10-4b41-4dac-a288-72a37afebbac/db2p-odse-v1.7.5.zip
Richard Deeming 29-Jul-21 9:28am     CRLF
You haven't shown us any code, nor any details of the error(s). You'll need to contact the people who provided you with the file, or whoever wrote the code, for support.
mathieudesmet2 29-Jul-21 9:37am     CRLF
true! The code : Dim mySigedis As New BeMaangifte.Sigedis_odse.SecondPillarPensionODSEDeclarationsResponseFile Dim myFile As New FileStream("\\ebcs.be\fileserver\Documenten\kbc\andere\Rapportering\2021\accountstates\odse test\responsetest.XML", FileMode.Open, FileAccess.Read) Dim objStreamReader As New StreamReader(myFile) Dim x As New System.Xml.Serialization.XmlSerializer(mySigedis.GetType) mySigedis = x.Deserialize(objStreamReader) The error {"There is an error in XML document (2, 2)."} <secondpillarpensionodsedeclarationsresponsefile xmlns="http://www.sigedis.be/db2p/declarations/odse/v1"> was not expected. I did not have this problem with other files, just this new kind of file I received : 'SecondPillarPensionODSEDeclarationsResponseFile'
Richard Deeming 29-Jul-21 9:40am    
There is a mis-match somewhere between your BeMaangifte.Sigedis_odse.SecondPillarPensionODSEDeclarationsResponseFile class and the XML file. Since we can't see the definition of that class, we can't tell you what the problem is.
mathieudesmet2 29-Jul-21 9:44am     CRLF
this is the Class > https://codeshare.io/MNkPyq this has been Autogenerated by the XSD tool that comes with Visual Studio

1 solution

Thank you for the tip !

Solution 1 found
I have changed this in my Class defintion

From
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://www.sigedis.be/db2p/declarations/odse/cbss-sigedis/v1", IsNullable:=False)>


to
System.Xml.Serialization.XmlRootAttribute([Namespace]:="http://www.sigedis.be/db2p/declarations/odse/v1", IsNullable:=False)>


Solution 2 found

I have CHANGED the input file with find replace

Dim fl As String = My.Computer.FileSystem.ReadAllText("responsetest.XML")
fl = fl.Replace("xmlns:db2p-declarations-odse=""http://www.sigedis.be/db2p/declarations/odse/v1""",
                "xmlns:db2p-declarations-odse=""http://www.sigedis.be/db2p/declarations/odse/cbss-sigedis/v1"""
                )
My.Computer.FileSystem.WriteAllText("responsetest.2.XML", fl, False)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900