Пример #1
0
 private static ApiServiceClient GetWcfClient()
 {
     ApiServiceClient client = new ApiServiceClient("Secure_ApiService");
     client.ClientCredentials.UserName.UserName = UserName;
     client.ClientCredentials.UserName.Password = Password;
     return client;
 }
Пример #2
0
        public static void TestGetTransmission()
        {
            using (var client = new ApiServiceClient())
            {
                //(if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    var transmissionId = ConfigurationManager.AppSettings["TransmissionId"];
                    Console.WriteLine("Calling API GetTransmission(\"{0}\")", transmissionId);

                    var transmission = client.GetTransmission(transmissionId);
                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }
Пример #3
0
 public WordOfDayModel GetWordOfDay()
 {
     using (var client = new ApiServiceClient())
     {
         return(client.GetLastWordOfTheDay().ToModel());
     }
 }
Пример #4
0
 public List <PhraseModel> GetPhrases(GetPhrasesRequest request)
 {
     using (var client = new ApiServiceClient())
     {
         var response = client.GetPhrase(request);
         return(response.Phrases == null ? new List <PhraseModel>() : response.Phrases.ToList().Select(x => x.PreparePhrase()).Select(x => x.ToModel()).ToList());
     }
 }
Пример #5
0
 public void Match(string keyword, string phrase, string deviceId = null, string accountId = null)
 {
     using (var client = new ApiServiceClient())
     {
         client.Match(new MatchRequest()
         {
             AccountId = accountId, DeviceId = deviceId, Phrase = phrase, Keyword = keyword
         });
     }
 }
Пример #6
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetWcfClient();

            PrintAllCampaigns();
            PrintEmptyLine();
            PrintAllAddressBooks();
        }
Пример #7
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetWcfClient();

            DateTime firstDayOfMonth = GetFirstDayOfMonth();
            IEnumerable<ApiCampaign> campaigns = GetAllCampaignWithActivity(firstDayOfMonth);

            PrintCampaigns(campaigns);
        }
Пример #8
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetWcfClient();

            ApiContact contact = CreateContact();
            PrintContact(contact);

            contact = UpdateEmail(contact);
            PrintContact(contact);

            DeleteContact(contact.Id);
        }
Пример #9
0
        public IApiService Build()
        {
            var path     = Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path);
            var rootPath = Path.GetDirectoryName(path);

            string certificateFilePath;

            switch (_transmittalEnvironment.TransmissionMode)
            {
            case ETransmissionMode.Test:
                certificateFilePath = $@"{rootPath}\Certificates\TestEnvironmentCertificate.CER";
                break;

            case ETransmissionMode.Production:
                certificateFilePath = $@"{rootPath}\Certificates\ProductionEnvironmentCertificate.CER";
                break;

            case ETransmissionMode.OnlyValidate:
                return(new ApiServiceClientMock(_transmittalEnvironment.SetupMockParameters));

            default:
                throw new ArgumentOutOfRangeException();
            }

            var binding = new WSHttpBinding(SecurityMode.Message);
            var message = new NonDualMessageSecurityOverHttp
            {
                ClientCredentialType       = MessageCredentialType.UserName,
                NegotiateServiceCredential = false,
                EstablishSecurityContext   = false
            };

            binding.Security.Message = message;

            var certificate     = new X509Certificate2(X509Certificate.CreateFromCertFile(certificateFilePath));
            var uri             = new Uri(_transmittalEnvironment.EndpointUrl);
            var endpointAddress = new EndpointAddress(uri, EndpointIdentity.CreateX509CertificateIdentity(certificate));

            var service = new ApiServiceClient(binding, endpointAddress);

            if (service.ClientCredentials == null)
            {
                throw new ArgumentNullException();
            }

            service.ClientCredentials.UserName.UserName = _transmittalEnvironment.Username;
            service.ClientCredentials.UserName.Password = Crypter.DecryptString(_transmittalEnvironment.Password);
            return(service);
        }
Пример #10
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetWcfClient();

            ApiAddressBook addressBook = CreateAddressBook();
            AddContactToAddressBook(addressBook);

            ApiCampaign campaign = CreateCampaign();

            ApiCampaignSend sendResult = SendCampaignToAddressBook(campaign, addressBook);
            WaitUntilSendFinishes(sendResult);

            PrintCampaingSummary(campaign);
        }
Пример #11
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;

            _client = GetWcfClient();

            byte[] contacts = GetContactsForImport();
            ApiContactImport contactImport = _client.ImportContactsToAddressBook(AddressBookId, contacts, "csv");
            ApiContactImport contactImportResult = WaitUntilImportFinishes(contactImport);
            PrintContactImport(contactImportResult);

            ApiContactImportReport contactImportReport = _client.GetContactImportReport(contactImportResult.Id);
            PrintContactImportReport(contactImportReport);

            string csvReport = GetContactImportFaults(contactImportResult.Id);
            PrintCsvReport(csvReport);
        }
Пример #12
0
        public static void TestGetDocuments()
        {
            using (var client = new ApiServiceClient())
            {
                // (if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    Console.WriteLine("Calling API GetDocuments(\"U\")");

                    // Make web service call to request unacknowledged registrations.
                    var transmission = client.GetDocuments("U");

                    /*
                     *
                     * // Write result xml to a file
                     * var xmlWriterSettings = new XmlWriterSettings { Encoding = new UTF8Encoding(false) };
                     * var xmlserializer = new XmlSerializer(transmission.GetType());
                     * string xml;
                     * using (var stringWriter = new StringWriter())
                     * {
                     *  using (var writer = XmlWriter.Create(stringWriter, xmlWriterSettings))
                     *  {
                     *      xmlserializer.Serialize(writer, transmission);
                     *      xml = stringWriter.ToString();
                     *  }
                     * }
                     * File.WriteAllText(path,xml);
                     */
                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }
Пример #13
0
        public async Task <ActionResult> ResetPassword(string serectCode, string newPassword, string email)
        {
            var data = Request.Cookies[email];

            if (data != null)
            {
                if (!data.Value.Equals(serectCode))
                {
                    return(RedirectToAction("CreateResetPassword", "Login", new { email = email }));
                }
                if (await ApiServiceClient.UserChangePassword(new UserDTO()
                {
                    UserPwd = newPassword,
                    UserEmail = email
                }))
                {
                    TempData["success"] = "Đổi mật khẩu thành công";
                    return(RedirectToAction("Login"));
                }
            }

            TempData["error"] = "Đổi mật khẩu không thành công";
            return(RedirectToAction("ResetPassword", "Login", new { email = email }));
        }
Пример #14
0
        public void ShouldStartManagingRegistration()
        {
            // load these from a file or something.
            var clients   = LoadClients();
            var header    = GetHeader();
            var documents = MapDocuments(clients);

            header.DocumentCount = documents.Count.ToString();

            var bulkRegister = new BulkRegistrationTransmissionType()
            {
                BulkRegistrationDocument = documents.ToArray(),
                TransmissionHeader       = header,
                transmissionVersion      = "SST2015V01",
            };

            Console.WriteLine(SerializeObjectToXmlString(bulkRegister));

            try
            {
                var client = new ApiServiceClient();

                client.ClientCredentials.UserName.UserName = "******";
                client.ClientCredentials.UserName.Password = "******";

                var response = client.BulkRegistration(bulkRegister);

                Console.WriteLine(SerializeObjectToXmlString(response));
            }
            catch (FaultException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.Code);
                Console.WriteLine(ex.Reason);
            }
        }
Пример #15
0
        public async Task <IHttpActionResult> SST([FromBody] JObject json)
        {
            IHttpActionResult res = await Task.Run <IHttpActionResult>(() =>
            {
                dynamic info = new ExpandoObject();

                //............. request info
                if (json == null)
                {
                    return(Ok("No UserName and Password supplied"));
                }
                dynamic request = json;
                if (string.IsNullOrEmpty(request.UserName.ToString()) || string.IsNullOrEmpty(request.Password.ToString()))
                {
                    return(Ok("No UserName and Password supplied"));
                }

                string xml      = request.xml.ToString();
                string userName = request.UserName.ToString();
                string password = request.Password.ToString();

                //............. init contentsTreeView
                info.type = "ok";
                ContentsTreeView <BulkRegistrationTransmissionType> contentsTreeView = new ContentsTreeView <BulkRegistrationTransmissionType>();

                contentsTreeView.ContentObject = new BulkRegistrationTransmissionType
                {
                    TransmissionHeader = new TransmissionHeaderType
                    {
                        Transmitter = new TransmissionHeaderTypeTransmitter()
                    },
                };
                contentsTreeView.RefreshTree();
                var p     = contentsTreeView.GetType().GetProperty("ContentObject");
                var types =
                    Assembly.GetExecutingAssembly()
                    .GetTypes()
                    .Where(
                        t =>
                        String.Equals(t.Namespace, contentsTreeView.ContentObject.GetType().Namespace,
                                      StringComparison.Ordinal) && t.IsClass && (!t.IsAbstract))
                    .ToArray();

                //............. write xml string to stream
                MemoryStream stream = new MemoryStream();
                StreamWriter writer = new StreamWriter(stream);
                writer.Write(xml);
                writer.Flush();
                stream.Position = 0;
                var ser         = new XmlSerializer(contentsTreeView.ContentObject.GetType(), types);
                p.SetValue(contentsTreeView, ser.Deserialize(stream));
                stream.Close();

                //............. sst check
                ApiServiceClient client = new ApiServiceClient
                {
                    ClientCredentials =
                    {
                        UserName     =
                        {
                            UserName = userName,
                            Password = password
                        }
                    }
                };
                try
                {
                    BulkRegistrationAcknowledgementType ack = null;
                    try
                    {
                        ack = client.BulkRegistration(contentsTreeView.ContentObject);
                    }
                    catch (Exception e)
                    {
                        client.Abort();
                        //........ try to register again
                        try
                        {
                            Thread.Sleep(1000);
                            client = new ApiServiceClient
                            {
                                ClientCredentials =
                                {
                                    UserName     =
                                    {
                                        UserName = userName,
                                        Password = password
                                    }
                                }
                            };
                            ack = client.BulkRegistration(contentsTreeView.ContentObject);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    ContentsTreeView <BulkRegistrationAcknowledgementType> resp_contentsTreeView =
                        new ContentsTreeView <BulkRegistrationAcknowledgementType>();
                    resp_contentsTreeView.ContentObject = ack;
                    resp_contentsTreeView.RefreshTree();


                    MemoryStream resp_stream = new MemoryStream();
                    StreamWriter resp_writer = new StreamWriter(resp_stream);
                    var resp_types           = Assembly.GetExecutingAssembly().GetTypes().Where(t => String.Equals(t.Namespace,
                                                                                                                   resp_contentsTreeView.ContentObject.GetType().Namespace, StringComparison.Ordinal) && t.IsClass && (!t.IsAbstract)).ToArray();
                    //var writer = new StreamWriter(saveFileDialog1.FileName);
                    var resp_ser = new XmlSerializer(resp_contentsTreeView.ContentObject.GetType(), types);
                    resp_ser.Serialize(resp_writer, resp_contentsTreeView.ContentObject);
                    resp_stream.Position = 0;
                    StreamReader reader  = new StreamReader(resp_stream);
                    string text          = reader.ReadToEnd();
                    stream.Close();
                    info.msg = text;

                    client.Abort();
                    //client.Close();
                }
                catch (TimeoutException toException)
                {
                    //The application timed out waiting for a response.
                    info.type = "error";
                    info.msg  = string.Format("<exception>{0}</exception>", toException.ToString());
                    client.Abort();
                    return(Ok(info));
                }
                return(Ok(info));
            });

            return(res);
        }
Пример #16
0
        public static void login()
        {
            try
            {
                //////////////////////////////////////////////////
                //DuplexChannelFactory<ISequoiaApiDualChannelService> factory =
                // new DuplexChannelFactory<ISequoiaApiDualChannelService>(m_SequoiaApiServiceCallback,
                // "endPointApiNetTcpWithCallback");



                ////////////////////////////////////////////////////////////////////
                ApiServiceClient apiSC = new ApiServiceClient("endPointApiNetTcpWithCallback");
                //bool logon = apiSC.Logon("api", "api");

                //Console.WriteLine(logon ? "Logged in!" : "Did not authenticate");

                //if (logon)
                //{
                //get job by reference
                DuplexChannelFactory <ISequoiaApiDualChannelService> factory = apiSC.GetChannelFactory();
                ISequoiaApiDualChannelService channel = factory.CreateChannel();
                SequoiaLogonResponse          result  = channel.Logon(new SequoiaLogonRequest {
                    UserName = "******",
                    Password = "******"
                });
                Console.WriteLine(result.Authenticated  ? "Logged in!" : "Did not authenticate");
                if (result.Authenticated)
                {
                    //Console.WriteLine(channel.GetApiVersion().ReturnValue);
                    m_SequoiaApiServiceCallback = new SequoiaApiServiceCallback();

                    ChannelFactory <IJobService> factory_job = new ChannelFactory <IJobService>("endPointJobService");
                    IJobService job_channel           = factory_job.CreateChannel();
                    GetJobByReferenceRequest req_job1 = new GetJobByReferenceRequest();
                    GetJobByReferenceRequest req_job2 = new GetJobByReferenceRequest();
                    GetJobByReferenceRequest req_job3 = new GetJobByReferenceRequest();
                    ////////////////////////////////////////////
                    req_job1.Reference = "AE015732";
                    GetJobByReferenceResponse jobResp = job_channel.GetJobByReference(req_job1);
                    int hash_code = job_channel.GetHashCode();
                    Console.WriteLine("Hash Code : " + hash_code.ToString());

                    Console.WriteLine("############JOB Details For " + req_job1.Reference + "############");

                    Console.WriteLine("Reference : " + jobResp.JobHeader.JobReference);
                    Console.WriteLine("Mode : " + jobResp.JobHeader.Mode.ToString());
                    Console.WriteLine("Type : " + jobResp.JobHeader.Type.ToString());
                    Console.WriteLine("CustomerAccountId : " + jobResp.JobHeader.CustomerAccountId.ToString());
                    Console.WriteLine("Created By : " + jobResp.JobHeader.CreatedBy.ToString());
                    Console.WriteLine("Created On : " + jobResp.JobHeader.CreatedOn.ToString());
                    Console.WriteLine("Modified By : " + jobResp.JobHeader.ModifiedBy.ToString());
                    Console.WriteLine("Modified On : " + jobResp.JobHeader.ModifiedOn.ToString());
                    Console.WriteLine("##########################################");
                    ////////////////////////////////////////////////////////////////////////////
                    req_job2.Reference = "OI030013";
                    GetJobByReferenceResponse jobResp2 = job_channel.GetJobByReference(req_job2);

                    Console.WriteLine("############JOB Details For " + req_job2.Reference + "############");

                    Console.WriteLine("Reference : " + jobResp2.JobHeader.JobReference);
                    Console.WriteLine("Mode : " + jobResp2.JobHeader.Mode.ToString());
                    Console.WriteLine("Type : " + jobResp2.JobHeader.Type.ToString());
                    Console.WriteLine("CustomerAccountId : " + jobResp2.JobHeader.CustomerAccountId.ToString());
                    Console.WriteLine("Created By : " + jobResp2.JobHeader.CreatedBy.ToString());
                    Console.WriteLine("Created On : " + jobResp2.JobHeader.CreatedOn.ToString());
                    Console.WriteLine("Modified By : " + jobResp2.JobHeader.ModifiedBy.ToString());
                    Console.WriteLine("Modified On : " + jobResp2.JobHeader.ModifiedOn.ToString());
                    Console.WriteLine("##########################################");
                    ////////////////////////////////////////////////////////////////////////////
                    req_job3.Reference = "AI030301";
                    GetJobByReferenceResponse jobResp3 = job_channel.GetJobByReference(req_job3);

                    Console.WriteLine("############JOB Details For " + req_job3.Reference + "############");

                    Console.WriteLine("Reference : " + jobResp3.JobHeader.JobReference);
                    Console.WriteLine("Mode : " + jobResp3.JobHeader.Mode.ToString());
                    Console.WriteLine("Type : " + jobResp3.JobHeader.Type.ToString());
                    Console.WriteLine("CustomerAccountId : " + jobResp3.JobHeader.CustomerAccountId.ToString());
                    Console.WriteLine("Created By : " + jobResp3.JobHeader.CreatedBy.ToString());
                    Console.WriteLine("Created On : " + jobResp3.JobHeader.CreatedOn.ToString());
                    Console.WriteLine("Modified By : " + jobResp3.JobHeader.ModifiedBy.ToString());
                    Console.WriteLine("Modified On : " + jobResp3.JobHeader.ModifiedOn.ToString());
                    Console.WriteLine("##########################################");
                    ////////////////////////////////////////////////////////////////////////////
                }
                //    GetJobByReferenceResponse jobResp = m_jobService.GetJobByReference(new GetJobByReferenceRequest
                //    {
                //        Reference = "TESTJOB"
                //    });

                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            Console.ReadLine();
        }
Пример #17
0
        public static void TestGetTransmission()
        {
            using (var client = new ApiServiceClient())
            {
                //(if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    var transmissionId = ConfigurationManager.AppSettings["TransmissionId"];
                    Console.WriteLine("Calling API GetTransmission(\"{0}\")", transmissionId);

                    var transmission = client.GetTransmission(transmissionId);

                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }
Пример #18
0
        public static void TestAcknowledgeTransmission()
        {
            using (var client = new ApiServiceClient())
            {
                // (if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    const string transmissionId = ""; // please provide valid TransmissionId
                    Console.WriteLine("Calling API AcknowledgeTransmission(\"{0}\")", transmissionId);

                    // prepare acknowledgement object
                    var ack = new SSTPAcknowledgementType
                    {
                        AcknowledgementHeader = new AcknowledgementHeaderType
                        {
                            AcknowledgementCount = "1",
                            AcknowledgementTimestamp = DateTime.UtcNow
                        },
                        DocumentAcknowledgement = new[]
                        {
                            new DocumentAcknowledgementType
                            {
                                DocumentId = "", // please provide a valid DocumentId
                                DocumentStatus = StatusType.R,
                                Errors = new Errors
                                {
                                    Error = new []
                                    {
                                        new Error
                                        {
                                            errorId = "1000",
                                            ErrorMessage = "Test Message"
                                        },
                                        new Error
                                        {
                                            errorId = "2000",
                                            ErrorMessage = "Test Message2",
                                            AdditionalErrorMessage = "AdditionalErrorMessage",
                                            Item = "FiledName",
                                            ItemElementName = ItemChoiceType.FieldIdentifier,
                                            DataValue = "Value",
                                            Severity = "Critical"
                                        }
                                    },
                                    errorCount = "2"
                                }
                            }
                        },
                        TransmissionAcknowledgement = new TransmissionAcknowledgementType
                        {
                            TransmissionId = "", // please provide valid TransmissionId
                            TransmissionStatus = StatusType.A
                        },
                        acknowledgementVersion = "SST2015V01"
                    };

                    var receipt = client.AcknowledgeTransmission(ack);

                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }
Пример #19
0
        public static void TestAcknowledgeTransmission()
        {
            using (var client = new ApiServiceClient())
            {
                // (if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    const string transmissionId = ""; // please provide valid TransmissionId
                    Console.WriteLine("Calling API AcknowledgeTransmission(\"{0}\")", transmissionId);

                    // prepare acknowledgement object
                    var ack = new SSTPAcknowledgementType
                    {
                        AcknowledgementHeader = new AcknowledgementHeaderType
                        {
                            AcknowledgementCount     = "1",
                            AcknowledgementTimestamp = DateTime.UtcNow
                        },
                        DocumentAcknowledgement = new[]
                        {
                            new DocumentAcknowledgementType
                            {
                                DocumentId     = "", // please provide a valid DocumentId
                                DocumentStatus = StatusType.R,
                                Errors         = new Errors
                                {
                                    Error = new []
                                    {
                                        new Error
                                        {
                                            errorId      = "1000",
                                            ErrorMessage = "Test Message"
                                        },
                                        new Error
                                        {
                                            errorId                = "2000",
                                            ErrorMessage           = "Test Message2",
                                            AdditionalErrorMessage = "AdditionalErrorMessage",
                                            Item            = "FiledName",
                                            ItemElementName = ItemChoiceType.FieldIdentifier,
                                            DataValue       = "Value",
                                            Severity        = "Critical"
                                        }
                                    },
                                    errorCount = "2"
                                }
                            }
                        },
                        TransmissionAcknowledgement = new TransmissionAcknowledgementType
                        {
                            TransmissionId     = "", // please provide valid TransmissionId
                            TransmissionStatus = StatusType.A
                        },
                        acknowledgementVersion = "SST2015V01"
                    };

                    var receipt = client.AcknowledgeTransmission(ack);
                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }
Пример #20
0
        public static void TestGetDocuments()
        {
            using (var client = new ApiServiceClient())
            {
                // (if used in production we recommend not storing your user/pass in the web.config)
                client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["SSTUser"];
                client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["SSTPass"];

                try
                {
                    Console.WriteLine("Calling API GetDocuments(\"U\")");

                    // Make web service call to request unacknowledged registrations.
                    var transmission = client.GetDocuments("U");

                    /*

                    // Write result xml to a file
                    var xmlWriterSettings = new XmlWriterSettings { Encoding = new UTF8Encoding(false) };
                    var xmlserializer = new XmlSerializer(transmission.GetType());
                    string xml;
                    using (var stringWriter = new StringWriter())
                    {
                        using (var writer = XmlWriter.Create(stringWriter, xmlWriterSettings))
                        {
                            xmlserializer.Serialize(writer, transmission);
                            xml = stringWriter.ToString();
                        }
                    }
                    File.WriteAllText(path,xml);
                    */
                }
                catch (MessageSecurityException)
                {
                    Console.WriteLine("Invalid login credentials or security certificate.");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    //Handle errors appropriately
                }
            }
        }