예제 #1
0
        public static void CheckNIP() //Metoda sprawdzająca nip lub kilka nipów w bazie danych. Korzysta z otwartej sesji w metodzi ConBIR
        {
            UslugaBIRzewnPublClient cc       = ConBIR();
            ParametryWyszukiwania   numerNip = new ParametryWyszukiwania();

            Console.WriteLine("Wprowadź nip lub kilka nipów oddzielonych przecinkiem : ");
            numerNip.Nipy = Console.ReadLine();
            string ret = cc.DaneSzukajPodmioty(numerNip);

            SerializeModule(ret);
            cc.Close();
        }
예제 #2
0
 public bool Close()
 {
     try
     {
         _client.Wyloguj(_sid);
         if (_client != null)
         {
             _client.Close();
             return(true);
         }
     }
     catch (Exception e)
     {
         throw new BiRClientSetUpException("Błąd podczas zamykania połączenia z usługą BiR", e);
     }
     return(false);
 }
예제 #3
0
        public static async Task <string> PobierzDane(string nip)
        {
            // WSHttpBinding myBinding = new WSHttpBinding();
            // myBinding.Security.Mode = SecurityMode.Transport;
            // myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            // myBinding.TextEncoding = Encoding.Unicode;              // WSMessageEncoding.Mtom;

            //  BasicHttpBinding b = new BasicHttpBinding();
            //  b.Security.Mode = BasicHttpSecurityMode.Transport;
            //  b.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            //  b.TextEncoding = Encoding.Unicode;

            string result;
            var    encoding  = new MtomMessageEncoderBindingElement(new TextMessageEncodingBindingElement());
            var    transport = new HttpsTransportBindingElement();

            var customBinding = new CustomBinding(encoding, transport);
            // bir.Endpoint.Binding = customBinding;

            EndpointAddress         ea = new EndpointAddress("https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc");
            UslugaBIRzewnPublClient cc = new UslugaBIRzewnPublClient(customBinding, ea);
            await cc.OpenAsync();

            ZalogujResponse r = await cc.ZalogujAsync("abcde12345abcde12345");

            using (OperationContextScope scope = new OperationContextScope(cc.InnerChannel))
            {
                System.ServiceModel.Channels.HttpRequestMessageProperty requestMessage = new System.ServiceModel.Channels.HttpRequestMessageProperty();
                requestMessage.Headers.Add("sid", r.ZalogujResult);
                OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] = requestMessage;
                // DANE SZUKAJ 1
                ParametryWyszukiwania objParametryGR1 = new ParametryWyszukiwania();
                objParametryGR1.Nip = nip;
                DaneSzukajPodmiotyResponse dane = await cc.DaneSzukajPodmiotyAsync(objParametryGR1);

                // File.WriteAllText(Directory.GetCurrentDirectory() + "\\wynik.xml", dane.DaneSzukajPodmiotyResult);
                result = dane.DaneSzukajPodmiotyResult;
                WylogujResponse w = await cc.WylogujAsync(r.ZalogujResult);

                cc.Close();
                return(result);
            }
        }