//Go to STARTUnitTest.classes for parameters and certificates config.
        public void SendSecureMessage()
        {
            //SSL Callback
            ServicePointManager.ServerCertificateValidationCallback = (sender, cert, chain, error) =>
            {
                return(true);
            };

            string                  endpointConfigurationName = Parameter.endpointConfigurationName;
            int                     assuranceLevel            = Parameter.assuranceLevel;
            string                  smlDomain          = "sml.peppolcentral.org";
            Uri                     thisUri            = Parameter.endpointAddress;
            X509Certificate2        clientCertificate  = Certificate.ClientCertificate;
            X509Certificate2        serviceCertificate = Certificate.ServiceCertificate;
            SimpleAccessPointClient target             = new SimpleAccessPointClient(endpointConfigurationName, assuranceLevel, smlDomain, thisUri, clientCertificate, serviceCertificate);

            IMessageMetadata metadata = new MessageMetadata();

            metadata.RecipientIdentifier        = new ParticipantIdentifierType();
            metadata.RecipientIdentifier.Value  = Parameter.recipientValue;
            metadata.RecipientIdentifier.scheme = Parameter.businessIdScheme;
            metadata.SenderIdentifier           = new ParticipantIdentifierType();
            metadata.SenderIdentifier.Value     = Parameter.senderValue;
            metadata.SenderIdentifier.scheme    = Parameter.businessIdScheme;
            metadata.DocumentIdentifier         = new DocumentIdentifierType();
            metadata.DocumentIdentifier.Value   = Parameter.documentIdValue;
            metadata.DocumentIdentifier.scheme  = Parameter.documentIdScheme;
            metadata.ProcessIdentifier          = new ProcessIdentifierType();
            metadata.ProcessIdentifier.Value    = Parameter.processIdValue;
            metadata.ProcessIdentifier.scheme   = Parameter.processIdScheme;
            metadata.ChannelIdentifier          = Parameter.senderValue;

            Random rnd = new Random((int)DateTime.Now.Ticks);

            metadata.MessageIdentifier = "uuid:" + Guid.NewGuid().ToString("D");

            XmlDocument body = new XmlDocument();

            body.LoadXml("<?xml version='1.0' encoding='UTF-8'?><s:Test xmlns:s=\"http://test.dk\">"
                         + "Message sent through 'SendMessage' unit test" + "</s:Test>");

            string actual = null;

            //Go to TestResults/Out folder to look TraceLog and SOAP messages.
            actual = target.Send(metadata, body);
        }
        static void PingProcess(string endpointConfigName, string endpointAddress, Certificates certificates)
        {
            IMessageMetadata metadata = new MessageMetadata()
            {
                RecipientIdentifier = new ParticipantIdentifierType()
                {
                    Value  = "busdox:recipient",
                    scheme = "busdox-actorid-transport"
                },
                SenderIdentifier = new ParticipantIdentifierType()
                {
                    Value  = "busdox:sender",
                    scheme = "busdox-actorid-transport"
                },

                DocumentIdentifier = new DocumentIdentifierType()
                {
                    Value  = "busdox:ping",
                    scheme = "busdox-docid-qns"
                },

                ProcessIdentifier = new ProcessIdentifierType()
                {
                    Value  = "busdox:noprocess",
                    scheme = "busdox-procid-transport"
                }
            };

            var secureClient = new SimpleAccessPointClient(endpointConfigName, int.Parse(ConfigurationManager.AppSettings["AssuranceLevel"]),
                                                           null,
                                                           new Uri(endpointAddress),
                                                           certificates.ClientCertificate,
                                                           certificates.ServiceCertificate);

            XmlDocument body = new XmlDocument();

            body.LoadXml("<Ping xmlns =\"http://busdox.org/transport/start/1.0/\"/>");

            Console.WriteLine("\nSending XML Ping..");
            secureClient.Send(metadata, body);

            Console.WriteLine("\nRemote server response was received successfully.");
        }
        public static void StartMessage(string endpointConfigName, Certificates certificates)
        {
            Console.WriteLine("\nInstantiating client..");

            string senderValue      = "9902:DK87654321";
            string recipientValue   = "9902:DK76543218";
            string businessIdScheme = "iso6523-actorid-upis";
            string documentIdScheme = "busdox-docid-qns";
            string documentIdValue  = "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:www.cenbii.eu:transaction:biicoretrdm010:ver1.0:#urn:www.peppol.eu:bis:peppol4a:ver1.0::2.0";
            string processIdValue   = "urn:www.cenbii.eu:profile:bii04:ver1.0";
            string processIdScheme  = "cenbii-procid-ubl";

            IMessageMetadata metadata = new MessageMetadata();

            metadata.RecipientIdentifier        = new ParticipantIdentifierType();
            metadata.RecipientIdentifier.Value  = recipientValue.ToLower();
            metadata.RecipientIdentifier.scheme = businessIdScheme;

            metadata.SenderIdentifier        = new ParticipantIdentifierType();
            metadata.SenderIdentifier.Value  = senderValue.ToLower();
            metadata.SenderIdentifier.scheme = businessIdScheme;

            metadata.DocumentIdentifier        = new DocumentIdentifierType();
            metadata.DocumentIdentifier.Value  = documentIdValue;
            metadata.DocumentIdentifier.scheme = documentIdScheme;

            metadata.ProcessIdentifier        = new ProcessIdentifierType();
            metadata.ProcessIdentifier.Value  = processIdValue;
            metadata.ProcessIdentifier.scheme = processIdScheme;

            string channelIdentifier = senderValue.ToLower();

            metadata.ChannelIdentifier = channelIdentifier;

            Random rnd = new Random((int)DateTime.Now.Ticks);

            metadata.MessageIdentifier = "uuid:" + Guid.NewGuid().ToString("D");

            XmlDocument body = new XmlDocument();

            body.Load(@"D:\path-to\MyDocument.xml");

            /* Lookup recipient participant */
            Helper help = new Helper();
            string recipientEndPointAddress = help.GetEndPointAddress(metadata.RecipientIdentifier.Value,
                                                                      metadata.RecipientIdentifier.scheme,
                                                                      ConfigurationManager.AppSettings["smlDomain"],
                                                                      metadata.DocumentIdentifier.scheme,
                                                                      metadata.DocumentIdentifier.Value);

            /* Start client and send */
            var secureClient = new SimpleAccessPointClient(endpointConfigName,
                                                           int.Parse(ConfigurationManager.AppSettings["AssuranceLevel"]),
                                                           ConfigurationManager.AppSettings["smlDomain"],
                                                           new Uri(recipientEndPointAddress),
                                                           certificates.ClientCertificate,
                                                           certificates.ServiceCertificate);

            Console.WriteLine("\nPlease Wait..");
            Console.WriteLine("\n" + secureClient.Send(metadata, body));
        }