Beispiel #1
0
 public aanleverenRequest(string aanleverkenmerk, string berichtsoort, identiteitType identiteitBelanghebbende, string rolBelanghebbende, string fileLocation, string autorisatieAdres)
 {
     // Create request
     aanleverRequest = new aanleverRequest
     {
         aanleverkenmerk          = aanleverkenmerk,
         berichtsoort             = berichtsoort,
         identiteitBelanghebbende = identiteitBelanghebbende,
         rolBelanghebbende        = rolBelanghebbende,
         berichtInhoud            = new berichtInhoudType
         {
             // File name to submit in message
             bestandsnaam = Path.GetFileName(fileLocation),
             // Read file as UTF-8 byte array
             inhoud   = FileIO.ReadFileToUtf8Array(fileLocation),
             mimeType = MediaTypeNames.Application.Xml
         },
         autorisatieAdres = autorisatieAdres
     };
 }
        private static void AanleverTest(WusClient wusClient)
        {
            Console.WriteLine("Creating request");

            ServiceReferenceAanleveren.identiteitType identity = new ServiceReferenceAanleveren.identiteitType("001000044B39", "BTW");
            aanleverenRequest aanleverRequest = wusClient.CreateAanleverRequest("Happyflow", "Omzetbelasting", identity, "Intermediair", SAMPLE_FILE);

            Console.WriteLine("Sending request");
            Console.WriteLine();

            Stopwatch timer = new Stopwatch();

            timer.Start();

            aanleverenResponse aanleverResponse = null;

            try
            {
                aanleverResponse = wusClient.Aanleveren(aanleverRequest);
            }
            catch (FaultException <ServiceReferenceAanleveren.foutType> ex)
            {
                Console.WriteLine(ex.Message);

                if (ex.Detail != null)
                {
                    Console.WriteLine($"{ex.Detail.foutcode} - {ex.Detail.foutbeschrijving}");
                }
            }
            // Handling known exceptions, including EndpointNotFoundException, MessageSecurityException, SecurityNegotiationException (derived from CommunicationException)
            catch (Exception ex) when(ex is CommunicationException || ex is TimeoutException)
            {
                Console.WriteLine(ex.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            if (aanleverResponse?.aanleverResponse == null)
            {
                Console.WriteLine();
                Console.WriteLine("No valid response received");
                //Console.ReadKey();
                Thread.Sleep(5000);
                return;
            }

            timer.Stop();

            Console.WriteLine($"Message ID (kenmerk): {aanleverResponse.aanleverResponse?.kenmerk}");
            Console.WriteLine($"Time stamp: {aanleverResponse.aanleverResponse?.tijdstempelAangeleverd}");
            Console.WriteLine($"Received response in {timer.Elapsed}");
            Console.WriteLine();

            if (wusClient.Profile.ConnectionStyle == WusConnectionProfile.WusConnectionStyle.asynchronous)
            {
                Console.WriteLine("Waiting 8 seconds before retrieving status...");
                Console.WriteLine();

                Thread.Sleep(8000);

                try
                {
                    getStatussenProcesResponse1 statusResponse = wusClient.StatusInformatie(aanleverResponse.aanleverResponse?.kenmerk);

                    if (statusResponse != null && statusResponse.getStatussenProcesResponse.getStatussenProcesReturn.Any())
                    {
                        StatusResultaat firstResult = statusResponse.getStatussenProcesResponse.getStatussenProcesReturn[0];

                        Console.WriteLine($"Kenmerk: {firstResult.kenmerk}");
                        Console.WriteLine($"Identity: {firstResult.identiteitBelanghebbende}");
                        Console.WriteLine();

                        foreach (StatusResultaat status in statusResponse.getStatussenProcesResponse.getStatussenProcesReturn)
                        {
                            Console.WriteLine($"Status: {status.statuscode} - {status.tijdstempelStatus} - {status.statusomschrijving}");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Unable to query status");
                    }
                }
                catch (FaultException <ServiceReferenceStatusInformatie.foutType> ex)
                {
                    Console.WriteLine(ex.Message);

                    if (ex.Detail != null)
                    {
                        Console.WriteLine($"{ex.Detail.foutcode} - {ex.Detail.foutbeschrijving}");
                    }
                }
                // Handling known exceptions, including EndpointNotFoundException, MessageSecurityException, SecurityNegotiationException (derived from CommunicationException)
                catch (Exception ex) when(ex is CommunicationException || ex is TimeoutException)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }
        }