Peppol bestand raadplegen via code

0000003310     -      24-10-2025

Het Peppol bestand (directory) kan geraadpleegd worden via code om de registratie van een deelnemer, geaccepteerde documenten, contactgegevens, enz. te controleren. De onderstaande code gebruikt de Rest API webservice van het Peppol bestand. De inhoud die door deze webservice wordt geretourneerd of de kwaliteit van de gegevens in deze inhoud vallen buiten de ondersteuning van Mercator. De code bevat een synchrone en een asynchrone methode.

Merk op dat we hier de directory raadplegen en niet de Peppol adresseringsgegevens. Ter herinnering: in Mercator kun je door met de rechtermuisknop op het BTW-nummer te klikken controleren of het aanwezig is op het Peppol-netwerk: in tegenstelling tot de hier gepresenteerde code raadpleegt deze functie de adresgegevens, die relevanter zijn dan de gegevens in het gegevensbestand. De gegevens in het bestand zijn alleen correct voor zover de door Peppol goedgekeurde providers ze bijwerken wanneer nieuwe abonnees zich bij hun netwerk aansluiten of wanneer de gegevens worden gewijzigd.

💡 Het antwoord op de vraag: "Is het mogelijk om via code de aanwezigheid van een klant op Peppol te controleren?" is dus JA. Met deze code en met kennis van de hierboven vermelde beperkingen.

Zoom
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using MercatorExtensions;

// <CompileWithRoslyn />

namespace TestTunnel
{
    public static class Class1
    {
        public static ParticipantResponse ParticipantInfo(string peppolId, out string error)
        {
            if (!peppolId.Contains(":"))
            {
                error = "Invalid peppolId!";
                return null;
            }
            string url = "https://directory.peppol.eu/search/1.0/json?participant=iso6523-actorid-upis::" + peppolId;

            MercatorExtensionsClass.JsonResultUpdater jsonResultUpdater = (jsonResult) =>
                jsonResult.Replace("-result-", "result")
                          .Replace("-page-", "page")
                          .Replace("query-terms", "queryterms")
                          .Replace("creation-dt", "creationdt");

#if (MERCATOR_CORE)
            MercatorHttpClient.HttpClient client = MercatorHttpClient.HttpClient.Create(url);
#else
            HttpWebRequest client = (HttpWebRequest)WebRequest.Create(url);
#endif
            client.Timeout = 2000;
            return client.GetData<ParticipantResponse>(jsonResultUpdater, out error);
        }

        public async static Task<(ParticipantResponse participantResponse, string error)> ParticipantInfoAsync(string peppolId)
        {
            if (!peppolId.Contains(":"))
                return (null, "Invalid peppolId!");
            
            string url = "https://directory.peppol.eu/search/1.0/json?participant=iso6523-actorid-upis::" + peppolId;

            MercatorExtensionsClass.JsonResultUpdater jsonResultUpdater = (jsonResult) =>
                jsonResult.Replace("-result-", "result")
                          .Replace("-page-", "page")
                          .Replace("query-terms", "queryterms")
                          .Replace("creation-dt", "creationdt");

#if (MERCATOR_CORE)
            MercatorHttpClient.HttpClient client = MercatorHttpClient.HttpClient.Create(url);
#else
            HttpWebRequest client = (HttpWebRequest)WebRequest.Create(url);
#endif
            client.Timeout = 2000;
            return await client.GetDataAsync<ParticipantResponse>(jsonResultUpdater);
        }
    }

    public class ParticipantResponse
    {
        public class Contact
        {
            public string type { get; set; }
            public string name { get; set; }
            public string phone { get; set; }
            public string email { get; set; }
        }

        public class DocType
        {
            public string scheme { get; set; }
            public string value { get; set; }
        }

        public class Entity
        {
            public List<Name> name { get; set; }
            public string countryCode { get; set; }
            public List<Identifier> identifiers { get; set; }
            public List<Contact> contacts { get; set; }
            public string regDate { get; set; }
        }

        public class Identifier
        {
            public string scheme { get; set; }
            public string value { get; set; }
        }

        public class Match
        {
            public ParticipantID participantID { get; set; }
            public List<DocType> docTypes { get; set; }
            public List<Entity> entities { get; set; }
        }

        public class Name
        {
            public string name { get; set; }
        }

        public class ParticipantID
        {
            public string scheme { get; set; }
            public string value { get; set; }
        }

        public string version { get; set; }
        public int totalresultcount { get; set; }
        public int usedresultcount { get; set; }
        public int resultpageindex { get; set; }
        public int resultpagecount { get; set; }
        public int firstresultindex { get; set; }
        public int lastresultindex { get; set; }
        public string queryterms { get; set; }
        public DateTime creationdt { get; set; }
        public List<Match> matches { get; set; }
    }
}

 

De synchrone code kan aangeroepen worden met deze code:

Zoom
ParticipantResponse participantInfo = Class1.ParticipantInfo("9925:be0411223337", out string error);

 

De asynchrone code kan aangeroepen worden met deze code:

Zoom
(ParticipantResponse participantInfo, string error) = await Class1.ParticipantInfoAsync("9925:be0411223337");


Functionele cookies: Cookies die nodig zijn voor het gebruik van de website en voorkeurscookies. Ze bevatten geen persoonsgegevens. (Meer informatie)

Analytische cookies: Verzamelen van statistieken met betrekking tot het gedrag van internetgebruikers. (Meer informatie)

Marketingcookies: Om bezoekers op verschillende websites te volgen voor advertentiedoeleinden. (Meer informatie)