public string Connect(string nips) { WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.MessageEncoding = WSMessageEncoding.Mtom; EndpointAddress ea = new EndpointAddress("https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc"); UslugaBIRzewnPublClient service = new UslugaBIRzewnPublClient(myBinding, ea); service.Open(); string sid = service.Zaloguj("abcde12345abcde12345"); new OperationContextScope(service.InnerChannel); HttpRequestMessageProperty reqProps = new HttpRequestMessageProperty(); reqProps.Headers.Add("sid", sid); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = reqProps; ParametryWyszukiwania parametryWyszukiwania = new ParametryWyszukiwania(); parametryWyszukiwania.Nipy = nips; return(service.DaneSzukajPodmioty(parametryWyszukiwania)); }
public void downloadPublDaneRaportFizycznaOsoba(string regon) { if (regon != "") { if (!File.Exists(xmlPath + "\\PublDaneRaportFizycznaOsoba\\" + regon + ".xml")) { string AdresUslugi = "https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc"; WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.MessageEncoding = WSMessageEncoding.Mtom; EndpointAddress ea = new EndpointAddress(AdresUslugi); UslugaBIRzewnPublClient cc = new UslugaBIRzewnPublClient(myBinding, ea); cc.Open(); string strSID = cc.Zaloguj(bir1Key); using (OperationContextScope scope = new OperationContextScope(cc.InnerChannel)) { HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers.Add("sid", strSID); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; //Szukaj ParametryWyszukiwania objParametryGR1 = new ParametryWyszukiwania(); string xmlFullRaport = cc.DanePobierzPelnyRaport(regon, "PublDaneRaportFizycznaOsoba"); File.WriteAllText(xmlPath + "\\PublDaneRaportFizycznaOsoba\\" + regon + ".xml", xmlFullRaport); } } } }
public static string regonFromNIP(string nip, string key) { try { string AdresUslugi = "https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc"; WSHttpBinding myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.MessageEncoding = WSMessageEncoding.Mtom; EndpointAddress ea = new EndpointAddress(AdresUslugi); UslugaBIRzewnPublClient cc = new UslugaBIRzewnPublClient(myBinding, ea); cc.Open(); string strSID = cc.Zaloguj(key); using (OperationContextScope scope = new OperationContextScope(cc.InnerChannel)) { HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers.Add("sid", strSID); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; //Szukaj ParametryWyszukiwania objParametryGR1 = new ParametryWyszukiwania(); objParametryGR1.Nip = nip; string searchXml = cc.DaneSzukaj(objParametryGR1); XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(searchXml); string regon = xdoc.SelectSingleNode("root/dane/Regon").InnerText; return(regon); } } catch { return(""); } }
public void Init() { try { WSHttpBinding binding = new WSHttpBinding(); binding.Security.Mode = SecurityMode.Transport; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; binding.MessageEncoding = WSMessageEncoding.Mtom; binding.AllowCookies = true; var endPoint = new EndpointAddress(_url); _client = new UslugaBIRzewnPublClient(binding, endPoint); _client.Open(); } catch (Exception e) { throw new BiRClientSetUpException("Błąd podczas otwierania klienta usluga BiR", e); } LogIn(true); SetMessageProperties(); }
public void PolaczBIRpub() { //Create the binding. var myBinding = new WSHttpBinding(SecurityMode.Transport); myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.MessageEncoding = WSMessageEncoding.Mtom; var ea = new EndpointAddress("https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc"); //test var client = new UslugaBIRzewnPublClient(myBinding, ea); client.Open(); //logowanie bez sida string sid = client.Zaloguj("123456789"); using (new OperationContextScope(client.InnerChannel)) { var requestMessage = new System.ServiceModel.Channels.HttpRequestMessageProperty(); requestMessage.Headers["sid"] = sid; OperationContext.Current.OutgoingMessageProperties[System.ServiceModel.Channels.HttpRequestMessageProperty.Name] = requestMessage; var paramGR1 = new UslugaBIRzewnPublClient(); } //'DANE SZUKAJ 1 //Dim objParametryGR1 As New UslugaBIRpubl.ParametryWyszukiwania //objParametryGR1.Nip = "1111111111" //txtResult.Text &= "### DaneSzukaj (grupa 1):" & vbCrLf & //cc.DaneSzukaj(objParametryGR1) & vbCrLf & vbCrLf //''DANE POBIERZ PEŁNY RAPORT //txtResult.Text &= "### DanePobierzPelnyRaport:" & vbCrLf & //cc.DanePobierzPelnyRaport("39002176400000", "PublDaneRaportPrawna", "") & vbCrLf & //vbCrLf //'WYLOGUJ //txtResult.Text &= "### Wyloguj:" & vbCrLf & cc.Wyloguj(strSID) & vbCrLf & //vbCrLf //'GET VALUE //txtResult.Text &= "### GetValue(KomunikatKod):" & vbCrLf & //cc.GetValue("KomunikatKod") & vbCrLf //txtResult.Text &= "### GetValue(KomunikatTresc):" & vbCrLf & //cc.GetValue("KomunikatTresc") & vbCrLf //txtResult.Text &= "### GetValue(StatusSesji):" & vbCrLf & //cc.GetValue("StatusSesji") & vbCrLf //End Using //cc.Close() //End Sub }
public static UslugaBIRzewnPublClient ConBIR() //Metoda Logująca się do GUSu i ustawiająca sid jako header komunikatów { GusKey apiKey = new GusKey(); WSHttpBinding myBinding = Binding(); EndpointAddress ea = new EndpointAddress("https://wyszukiwarkaregontest.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc"); UslugaBIRzewnPublClient cc = new UslugaBIRzewnPublClient(myBinding, ea); cc.Open(); string sid = cc.Zaloguj(apiKey.Key); Console.WriteLine("Zaloguj " + sid); OperationContextScope scope = new OperationContextScope(cc.InnerChannel); HttpRequestMessageProperty reqProps = new HttpRequestMessageProperty(); reqProps.Headers.Add("sid", sid); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = reqProps; return(cc); }
private static string Login() { if (Client != null && !string.IsNullOrEmpty(Sid)) { Client.Wyloguj(Sid); Client.Close(); } var appSettings = ConfigurationManager.AppSettings; var apiKey = appSettings["GusProdKey"]; Client = new UslugaBIRzewnPublClient(); Client.Open(); Sid = Client.Zaloguj(apiKey); if (string.IsNullOrEmpty(Sid)) { apiKey = appSettings["GusTestKey"]; Sid = Client.Zaloguj(apiKey); } return(Sid); }