![]() |
|
wsdl veri çekme hatası - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Genel Programlama (https://www.delphican.com/forumdisplay.php?fid=6) +--- Konu Başlığı: wsdl veri çekme hatası (/showthread.php?tid=8014) |
wsdl veri çekme hatası - tuna - 14-01-2025 Merhaba. wsdl xml web servisten veri çekmeye çalışıyorum ne yaparsam yapayım delphi tarafında verileri çekemedim. Verdiği hata Project Project1.exe raised exception class ENetHTTPClientException with message 'Error sending data: (12007) Sunucu adı veya adresi çözümlenemedi'. Sunucu adresinde hiçbir problem yok. SOAPUI aracı ile sorunsuz olarak verileri alabiliyorum. Delphi 12.2 versiyonu kullanıyorum. metodum bu şekilde. aşağıda da wsdl importer ile indirdiğim kısım var. uses InvoicesService;
procedure TForm2.Button1Click(Sender: TObject);
var
servis:IInvoicesService;
fatura:getInvoicesWithDetailsResult;
begin
servis:=GetIInvoicesService(true);
fatura:=servis.getInvoicesWithDetails('kullancıadı','sifre');
end;
wsdl importer ile oluşan dosya (ip adresini ** yaptım normalde doğru adres var orada) unit InvoicesService;
interface
uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;
const
IS_OPTN = $0001;
IS_REF = $0080;
type
getInvoicesWithDetailsResult = TXMLData; { "http://tempuri.org/"[CplxMxd] }
getInvoiceResult = TXMLData; { "http://tempuri.org/"[CplxMxd] }
getInvoiceWithDetailResult = TXMLData; { "http://tempuri.org/"[CplxMxd] }
getInvoicesResult = TXMLData; { "http://tempuri.org/"[CplxMxd] }
// ************************************************************************ //
// ************************************************************************ //
IInvoicesService = interface(IInvokable)
['{086E0D8F-2BC0-9B64-6E7F-811659574CDC}']
function getInvoices(const username: string; const password: string): getInvoicesResult; stdcall;
function getInvoicesWithDetails(const username: string; const password: string): getInvoicesWithDetailsResult; stdcall;
function setAsReceived(const username: string; const password: string; const invoiceId: Integer): Boolean; stdcall;
function getInvoice(const username: string; const password: string; const invoiceId: Integer): getInvoiceResult; stdcall;
function getInvoiceWithDetail(const username: string; const password: string; const invoiceId: Integer): getInvoiceWithDetailResult; stdcall;
end;
function GetIInvoicesService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IInvoicesService;
implementation
uses System.SysUtils;
function GetIInvoicesService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IInvoicesService;
const
defWSDL = 'http://100.**.**.12/InvoicesService.svc?singleWsdl';
defURL = 'http://100.**.**.12/InvoicesService.svc';
defSvc = 'InvoicesService';
defPrt = 'WSHttpBinding_IInvoicesService';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as IInvoicesService);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
initialization
{ IInvoicesService }
InvRegistry.RegisterInterface(TypeInfo(IInvoicesService), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IInvoicesService), 'http://tempuri.org/IInvoicesService/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(IInvoicesService), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(IInvoicesService), ioSOAP12);
{ IInvoicesService.getInvoices }
InvRegistry.RegisterMethodInfo(TypeInfo(IInvoicesService), 'getInvoices', '',
'[ReturnName="getInvoicesResult"]', IS_OPTN);
{ IInvoicesService.getInvoicesWithDetails }
InvRegistry.RegisterMethodInfo(TypeInfo(IInvoicesService), 'getInvoicesWithDetails', '',
'[ReturnName="getInvoicesWithDetailsResult"]', IS_OPTN);
{ IInvoicesService.setAsReceived }
InvRegistry.RegisterMethodInfo(TypeInfo(IInvoicesService), 'setAsReceived', '',
'[ReturnName="setAsReceivedResult"]');
{ IInvoicesService.getInvoice }
InvRegistry.RegisterMethodInfo(TypeInfo(IInvoicesService), 'getInvoice', '',
'[ReturnName="getInvoiceResult"]', IS_OPTN);
{ IInvoicesService.getInvoiceWithDetail }
InvRegistry.RegisterMethodInfo(TypeInfo(IInvoicesService), 'getInvoiceWithDetail', '',
'[ReturnName="getInvoiceWithDetailResult"]', IS_OPTN);
RemClassRegistry.RegisterXSInfo(TypeInfo(getInvoicesWithDetailsResult), 'http://tempuri.org/', 'getInvoicesWithDetailsResult');
RemClassRegistry.RegisterXSInfo(TypeInfo(getInvoiceResult), 'http://tempuri.org/', 'getInvoiceResult');
RemClassRegistry.RegisterXSInfo(TypeInfo(getInvoiceWithDetailResult), 'http://tempuri.org/', 'getInvoiceWithDetailResult');
RemClassRegistry.RegisterXSInfo(TypeInfo(getInvoicesResult), 'http://tempuri.org/', 'getInvoicesResult');
end.
Cvp: wsdl veri çekme hatası - hi_selamlar - 14-01-2025 (14-01-2025, Saat: 21:19)tuna Adlı Kullanıcıdan Alıntı: Merhaba. Merhaba, Dosyanız (Delphi 12.2 ) internet çıkışı (firewall / AV vb.) bloklanmış olabilir mi? Dosyanızı compile edip sonra manuel olarak klasörünüzden çalıştırıp denediniz mi hiç? Kolay gelsin. Cvp: wsdl veri çekme hatası - m_ekici - 15-01-2025 Merhaba SoapUi de çalışıyor ise orada çalışan kodu kullandığın THTTPRIO componentinin onBeforeExecute eventine çalışan kodu yazarak denermisin? procedure TKForm1.HTTPRIO_TESTBeforeExecute(const MethodName: string;
SOAPRequest: TStream);
var
StrStream: TStringStream;
St: string;
begin
StrStream:= TStringStream.Create('');
SOAPRequest.Position:= 0;
with StrStream do
begin
WriteString('<?xml version="1.0" encoding="UTF-8"?>');
WriteString('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '+
'xmlns:web="http://www.gtb.gov.tr//WebServices" xmlns:gtb="http://schemas.datacontract.org/2004/07/GTB.HKS.Bildirim.ServiceContract" '+
'xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">');
WriteString(' <soapenv:Header/>');
WriteString(' <soapenv:Body>');
WriteString(' <web:BaseRequestMessageOf_KayitliKisiSorguIstek>');
WriteString(' <web:Istek>');
WriteString(' <gtb:TcKimlikVergiNolar>');
WriteString(' <arr:string>'+TCkNoEdt.Text+'</arr:string>');
WriteString(' </gtb:TcKimlikVergiNolar>');
WriteString(' </web:Istek>');
WriteString(' <web
Cvp: wsdl veri çekme hatası - tuna - 15-01-2025 (14-01-2025, Saat: 22:56)hi_selamlar Adlı Kullanıcıdan Alıntı:(14-01-2025, Saat: 21:19)tuna Adlı Kullanıcıdan Alıntı: Merhaba. Merhaba dediğiniz şekilde denedim ama değişen birşey olmadı. Zaten bloklansa SOAPUI da da veri gelmez. (15-01-2025, Saat: 00:56)m_ekici Adlı Kullanıcıdan Alıntı: Merhaba Merhaba cevabınızı tam olarak anlamadım. Bu web servisten bana geri xml dönüyor. Bu xml'i nasıl yakalıycam. Orayı anlamadım. Cvp: wsdl veri çekme hatası - m_ekici - 15-01-2025 Merhaba WSDL den bilgi alırken THTTPRIO komponenti ile alıyorum. Aşağıdaki örnekte çiftçi sıfatlarını alıyorum. ama üst kısımı ne kadar doğru yazsam da wsdl import ederken yapı (anlamadığım şekilde) farklı gelebiliyor. O nedenle HTTPRIO_SIFATonbeforeexecute eventına servisten bilgi çekecek (SOAPIu da çalışan) kodu yazıyorum. Servise oraya yazdığım kod gidiyor. HTTPRIO_SIFAT: THTTPRIO; HTTPRIO_SIFAT.HTTPWebNode.UserName := utf8encode(DBF.GTB_Kuladi);
HTTPRIO_SIFAT.HTTPWebNode.Password := utf8encode(DBF.GTB_Sifre);
HTTPRIO_SIFAT.HTTPWebNode.ClientCertificate.CertName := GTB_Certf;
HTTPRIO_SIFAT.HTTPWebNode.UseUTF8InHeader:=true;
Info_BServis := GetIBildirimService(False,'',HTTPRIO_SIFAT);
Info_BReqM_KKSorguIstek := BaseRequestMessageOf_KayitliKisiSorguIstek.Create;
Info_BReqM_KKSorguIstek.UserName := HKULADI.Text;
Info_BReqM_KKSorguIstek.Password := HSIFRE.Text;
Info_BReqM_KKSorguIstek.ServicePassword := SSIFRE.Text;
Info_KKisiSorguIstek := KayitliKisiSorguIstek.Create;
SetLength(Info_TCNolari,1);
Info_TCNolari[0] := TCkNoEdt.Text;
Info_KKisiSorguIstek.TcKimlikVergiNolar := Info_TCNolari;
Info_BReqM_KKSorguIstek.Istek := Info_KKisiSorguIstek;
Info_BResM_KKSorguCevap := Info_BServis.BildirimServisKayitliKisiSorgu(Info_BReqM_KKSorguIstek);
SonucMesaj := '';
if Info_BResM_KKSorguCevap.IslemKodu<>GTB_SonucOk then
begin // Hata
for I := Low(Info_BResM_KKSorguCevap.HataKodlari) to High(Info_BResM_KKSorguCevap.HataKodlari) do
SonucMesaj := dbf.HKS_Sonuc(Info_BResM_KKSorguCevap.IslemKodu) + ' ' +IntToStr(Info_BResM_KKSorguCevap.HataKodlari[I].HataKodu)+':'+Info_BResM_KKSorguCevap.HataKodlari[I].Mesaj;
XmlSonuc.Memo1.Lines.Add('-------------------------');
XmlSonuc.Memo1.Lines.Add(SonucMesaj);
XmlSonuc.Memo1.Lines.Add('-------------------------');
XmlSonuc.ShowModal;
end
else // if Info_BResM_KKSorguCevap.IslemKodu=GTB_SonucOk then
begin
Info_KKisiSorguCevap := Info_BResM_KKSorguCevap.Sonuc;
EKL := 0; DEG := 0;
for I := Low(Info_KKisiSorguCevap.TcKimlikVergiNolar) to High(Info_KKisiSorguCevap.TcKimlikVergiNolar) do
begin
KayitliMi := Info_KKisiSorguCevap.TcKimlikVergiNolar[I].KayitliKisiMi;
if not KayitliMi then Mesaj.ShowMesaj('Bu TC Kimlik/Vergi No GTB Sisteminde kayıtlı değil...('+SonucMesaj+')',KrUnlem, mbDikkat, false) else
begin // Cari Kayıtlı ise
Info_Sifatlar := Info_KKisiSorguCevap.TcKimlikVergiNolar[I].Sifatlari;
for J := Low(Info_Sifatlar) to High(Info_Sifatlar) do
begin
B_ID := Info_Sifatlar[J];
{
for K := 0 to SSEC_.Properties.Items.Count - 1 do
begin
if SSEC_.Properties.Items[K].Tag=B_ID then SSEC_.States[J] := cbsChecked;
end;
}
end;
end;
end;
end;
EXCEPT
Mesaj.ShowMesaj('Bağlantı Hatası....!!', KrHata, mbHata, false);
exit;
END;
wsdl veri çekme hatası - tuna - 15-01-2025 Cevap için çok teşekkür ederim. Biraz sizin yazdığınız birazda chatgpt ile sorunu çözdüm. Şuan veriler geliyor. Cvp: wsdl veri çekme hatası - hi_selamlar - 15-01-2025 (15-01-2025, Saat: 13:27)tuna Adlı Kullanıcıdan Alıntı: Cevap için çok teşekkür ederim. Biraz sizin yazdığınız birazda chatgpt ile sorunu çözdüm. Şuan veriler geliyor. Merhaba, Nasıl çözümlediğinizi ve hatanın ne olduğunuda yazarsanız, aynı sorun ile karşılacak arkadaşlar için bir yol olmuş olur. Kolay gelsin. |