private void button1_Click(object sender, EventArgs e)
        {
            peako.pekaoccs00101            loWSDL = new peako.pekaoccs00101();
            peako.MessageIdentyfication1   loMsgId;
            peako.StatementQueryDefinition loQuery;
            peako.GetStatement             loStatement;
            peako.StatementRequest         loRequest;
            peako.StatementResponse        loResponse;
            String lvXml = textXml.Text;

            loMsgId    = new peako.MessageIdentyfication1();
            loMsgId.Id = "GS201109050031111111";

            loQuery                                               = new peako.StatementQueryDefinition();
            loQuery.StmtCrit                                      = new peako.StatementCriteria();
            loQuery.StmtCrit.NewCrit                              = new peako.NewCriteria1();
            loQuery.StmtCrit.NewCrit.SchCrit                      = new peako.SearchCriteria1();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtFrmt             = peako.StatementFormat.XML;
            loQuery.StmtCrit.NewCrit.SchCrit.AcctId               = new peako.AccountIdentification1();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt            = new peako.StatementValueSearch();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt.DtSch      = new peako.DatePeriodDetails2();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt.DtSch.Item = new DateTime(2018, 04, 23);


            loQuery.StmtCrit.NewCrit.SchCrit.AcctId.EQ = new peako.AccountIdentification3Choice1
            {
                ItemElementName = peako.ItemChoiceType14.IBAN,
                Item            = "PL90124062921111001045475455"
            };

            loStatement            = new peako.GetStatement();
            loStatement.MsgId      = loMsgId;
            loStatement.StmtQryDef = loQuery;

            loRequest                  = new peako.StatementRequest();
            loRequest.Document         = new peako.Document2();
            loRequest.Document.GetStmt = loStatement;

            try
            {
                loWSDL.ClientCertificates.Add(new X509Certificate2(@"C:\Users\Ania\Downloads\cis_22705460.p12"));
                loResponse = loWSDL.GetStatement(loRequest);
                MessageBox.Show(loResponse.ToString());
            } catch (Exception loError)
            {
                MessageBox.Show(loError.ToString());
            }
        }
        public string getStatement(string cert, string MsgId, string AccId, bool byear, DateTime Dt, string format = "XML", string StId = " ")
        {
            /* cert - path to certificate file *.p12
             * MsgId - Message Id
             * AccId - Account Id
             * byear - true (method takes year and Statement Id) / false (method takes only date to statement request)
             * Dt - date
             * format - format of response (XML / PDF)
             * StId - Statement Id
             */

            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

            peako.pekaoccs00101            loWSDL = new peako.pekaoccs00101();
            peako.MessageIdentyfication1   loMsgId;
            peako.StatementQueryDefinition loQuery;
            peako.GetStatement             loStatement;
            peako.StatementRequest         loRequest;
            peako.StatementResponse        loResponse;

            //--- Message Id
            loMsgId    = new peako.MessageIdentyfication1();
            loMsgId.Id = MsgId;

            loQuery                          = new peako.StatementQueryDefinition();
            loQuery.StmtCrit                 = new peako.StatementCriteria();
            loQuery.StmtCrit.NewCrit         = new peako.NewCriteria1();
            loQuery.StmtCrit.NewCrit.SchCrit = new peako.SearchCriteria1();

            //--- Format
            if (format == "XML")
            {
                loQuery.StmtCrit.NewCrit.SchCrit.StmtFrmt = peako.StatementFormat.XML;
            }
            else
            {
                loQuery.StmtCrit.NewCrit.SchCrit.StmtFrmt = peako.StatementFormat.PDF;
            }

            loQuery.StmtCrit.NewCrit.SchCrit.AcctId          = new peako.AccountIdentification1();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt       = new peako.StatementValueSearch();
            loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt.DtSch = new peako.DatePeriodDetails2();

            //--- Statement by date / year + Statement Id
            if (byear == false)
            {
                loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt.DtSch.Item = Dt;
            }
            else
            {
                loQuery.StmtCrit.NewCrit.SchCrit.StmtValDt.DtSch.Item = Dt.Year.ToString();
                loQuery.StmtCrit.NewCrit.SchCrit.StmtId = new peako.StatementId
                {
                    EQ = StId
                };
            }

            loQuery.StmtCrit.NewCrit.SchCrit.AcctId.EQ = new peako.AccountIdentification3Choice1
            {
                ItemElementName = peako.ItemChoiceType14.IBAN,
                Item            = AccId
            };

            loStatement            = new peako.GetStatement();
            loStatement.MsgId      = loMsgId;
            loStatement.StmtQryDef = loQuery;

            loRequest = new peako.StatementRequest
            {
                Document = new peako.Document2()
            };

            loRequest.Document.GetStmt = loStatement;

            try
            {
                loWSDL.ClientCertificates.Add(new X509Certificate2(@cert));
                loResponse = loWSDL.GetStatement(loRequest);

                //convert response to string
                var stringwriter = new System.IO.StringWriter();
                var serializer   = new XmlSerializer(loResponse.Item.GetType());
                serializer.Serialize(stringwriter, loResponse.Item);
                string lvtext = stringwriter.ToString();

                lvtext = lvtext.Replace(" xmlns=\"urn:iso:std:iso:20022:tech:xsd:camt.053.001.02\"", "");

                MessageBox.Show(lvtext);
                return(lvtext);
            }
            catch (Exception loError)
            {
                MessageBox.Show(loError.ToString());
            }
            return("Error");
        }