public static void Main() { UslugaBIRzewnPublClient uslugaBIRzewnPublClient = new UslugaBIRzewnPublClient(); uslugaBIRzewnPublClient.ZalogujAsync("abcde12345abcde12345"); Task <DaneSzukajPodmiotyResponse> response = uslugaBIRzewnPublClient.DaneSzukajPodmiotyAsync(new ParametryWyszukiwania { Nip = "6452521870" }); Console.WriteLine(response.Result.DaneSzukajPodmiotyResult); }
public async Task <T> szukajPodmioty <T>(string nip) { OperationContextScope scope = new OperationContextScope(uslugaBIRzewn.InnerChannel); HttpRequestMessageProperty httpRequest = new HttpRequestMessageProperty(); httpRequest.Headers.Add("sid", sid); OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequest; var parametrSzukajKontrahenta = new ParametryWyszukiwania { Nip = nip }; var response = await uslugaBIRzewn.DaneSzukajPodmiotyAsync(parametrSzukajKontrahenta); return(DeserializeFromXml <T>(response.DaneSzukajPodmiotyResult)); }
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); } }