Sürat Kargo Gönderi web servisi

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
greenegitim
Üye
Mesajlar: 713
Kayıt: 28 Nis 2011 10:33
Konum: İstanbul

Sürat Kargo Gönderi web servisi

Mesaj gönderen greenegitim »

Merhaba Sürat kargonun http://www.suratkargo.com.tr/GonderiWeb ... .asmx?WSDL adresinden wsdl import ile delphide import ettim içeriği aşağıdaki gibi button click olayındada gönderme işlemi yapıyorum ama verdiği hata
"Server was unable to read request. ---> There is an error in XML document (2, 724)"
Soapui ile deneme yaptığımda bir sıkıntı yok forumdaki daha önce sorulan
viewtopic.php?t=35227
viewtopic.php?t=35770
gibi de denedim aynı hatayı almaya devam ediyorum eksik bir şeymi yapıyorum?

Kod: Tümünü seç

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx?WSDL
//  >Import : http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx?WSDL>0
// Encoding : utf-8
// Version  : 1.0
// (24.06.2016 23:27:56 - - $Rev: 76228 $)
// ************************************************************************ //

unit USuratKargoGonderiService;

interface

uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_REF  = $0080;


type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Embarcadero types; however, they could also 
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:decimal         - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:int             - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:unsignedByte    - "http://www.w3.org/2001/XMLSchema"[Gbl]

  Gonderi              = class;                 { "http://tempuri.org/"[GblCplx] }



  // ************************************************************************ //
  // XML       : Gonderi, global, <complexType>
  // Namespace : http://tempuri.org/
  // ************************************************************************ //
  Gonderi = class(TRemotable)
  private
    FKisiKurum: string;
    FKisiKurum_Specified: boolean;
    FSahisBirim: string;
    FSahisBirim_Specified: boolean;
    FAliciAdresi: string;
    FAliciAdresi_Specified: boolean;
    FIl: string;
    FIl_Specified: boolean;
    FIlce: string;
    FIlce_Specified: boolean;
    FTelefonEv: string;
    FTelefonEv_Specified: boolean;
    FTelefonIs: string;
    FTelefonIs_Specified: boolean;
    FTelefonCep: string;
    FTelefonCep_Specified: boolean;
    FEmail: string;
    FEmail_Specified: boolean;
    FAliciKodu: string;
    FAliciKodu_Specified: boolean;
    FKargoTuru: Byte;
    FOdemetipi: Byte;
    FIrsaliyeSeriNo: string;
    FIrsaliyeSeriNo_Specified: boolean;
    FIrsaliyeSiraNo: string;
    FIrsaliyeSiraNo_Specified: boolean;
    FReferansNo: string;
    FReferansNo_Specified: boolean;
    FOzelKargoTakipNo: string;
    FOzelKargoTakipNo_Specified: boolean;
    FAdet: Integer;
    FBirimDesi: TXSDecimal;
    FBirimKg: TXSDecimal;
    FKargoIcerigi: string;
    FKargoIcerigi_Specified: boolean;
    FKapidanOdemeTahsilatTipi: Byte;
    FKapidanOdemeTutari: TXSDecimal;
    FEkHizmetler: string;
    FEkHizmetler_Specified: boolean;
    FSevkAdresiAdi: string;
    FSevkAdresiAdi_Specified: boolean;
    FTeslimSekli: Byte;
    FTasimaSekli: Byte;
    FBayiNo: string;
    FBayiNo_Specified: boolean;
    FEntegrasyonId: string;
    FEntegrasyonId_Specified: boolean;
    FEntegrasyonHesaplamaTuru: string;
    FEntegrasyonHesaplamaTuru_Specified: boolean;
    procedure SetKisiKurum(Index: Integer; const Astring: string);
    function  KisiKurum_Specified(Index: Integer): boolean;
    procedure SetSahisBirim(Index: Integer; const Astring: string);
    function  SahisBirim_Specified(Index: Integer): boolean;
    procedure SetAliciAdresi(Index: Integer; const Astring: string);
    function  AliciAdresi_Specified(Index: Integer): boolean;
    procedure SetIl(Index: Integer; const Astring: string);
    function  Il_Specified(Index: Integer): boolean;
    procedure SetIlce(Index: Integer; const Astring: string);
    function  Ilce_Specified(Index: Integer): boolean;
    procedure SetTelefonEv(Index: Integer; const Astring: string);
    function  TelefonEv_Specified(Index: Integer): boolean;
    procedure SetTelefonIs(Index: Integer; const Astring: string);
    function  TelefonIs_Specified(Index: Integer): boolean;
    procedure SetTelefonCep(Index: Integer; const Astring: string);
    function  TelefonCep_Specified(Index: Integer): boolean;
    procedure SetEmail(Index: Integer; const Astring: string);
    function  Email_Specified(Index: Integer): boolean;
    procedure SetAliciKodu(Index: Integer; const Astring: string);
    function  AliciKodu_Specified(Index: Integer): boolean;
    procedure SetIrsaliyeSeriNo(Index: Integer; const Astring: string);
    function  IrsaliyeSeriNo_Specified(Index: Integer): boolean;
    procedure SetIrsaliyeSiraNo(Index: Integer; const Astring: string);
    function  IrsaliyeSiraNo_Specified(Index: Integer): boolean;
    procedure SetReferansNo(Index: Integer; const Astring: string);
    function  ReferansNo_Specified(Index: Integer): boolean;
    procedure SetOzelKargoTakipNo(Index: Integer; const Astring: string);
    function  OzelKargoTakipNo_Specified(Index: Integer): boolean;
    procedure SetKargoIcerigi(Index: Integer; const Astring: string);
    function  KargoIcerigi_Specified(Index: Integer): boolean;
    procedure SetEkHizmetler(Index: Integer; const Astring: string);
    function  EkHizmetler_Specified(Index: Integer): boolean;
    procedure SetSevkAdresiAdi(Index: Integer; const Astring: string);
    function  SevkAdresiAdi_Specified(Index: Integer): boolean;
    procedure SetBayiNo(Index: Integer; const Astring: string);
    function  BayiNo_Specified(Index: Integer): boolean;
    procedure SetEntegrasyonId(Index: Integer; const Astring: string);
    function  EntegrasyonId_Specified(Index: Integer): boolean;
    procedure SetEntegrasyonHesaplamaTuru(Index: Integer; const Astring: string);
    function  EntegrasyonHesaplamaTuru_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property KisiKurum:                string      Index (IS_OPTN) read FKisiKurum write SetKisiKurum stored KisiKurum_Specified;
    property SahisBirim:               string      Index (IS_OPTN) read FSahisBirim write SetSahisBirim stored SahisBirim_Specified;
    property AliciAdresi:              string      Index (IS_OPTN) read FAliciAdresi write SetAliciAdresi stored AliciAdresi_Specified;
    property Il:                       string      Index (IS_OPTN) read FIl write SetIl stored Il_Specified;
    property Ilce:                     string      Index (IS_OPTN) read FIlce write SetIlce stored Ilce_Specified;
    property TelefonEv:                string      Index (IS_OPTN) read FTelefonEv write SetTelefonEv stored TelefonEv_Specified;
    property TelefonIs:                string      Index (IS_OPTN) read FTelefonIs write SetTelefonIs stored TelefonIs_Specified;
    property TelefonCep:               string      Index (IS_OPTN) read FTelefonCep write SetTelefonCep stored TelefonCep_Specified;
    property Email:                    string      Index (IS_OPTN) read FEmail write SetEmail stored Email_Specified;
    property AliciKodu:                string      Index (IS_OPTN) read FAliciKodu write SetAliciKodu stored AliciKodu_Specified;
    property KargoTuru:                Byte        read FKargoTuru write FKargoTuru;
    property Odemetipi:                Byte        read FOdemetipi write FOdemetipi;
    property IrsaliyeSeriNo:           string      Index (IS_OPTN) read FIrsaliyeSeriNo write SetIrsaliyeSeriNo stored IrsaliyeSeriNo_Specified;
    property IrsaliyeSiraNo:           string      Index (IS_OPTN) read FIrsaliyeSiraNo write SetIrsaliyeSiraNo stored IrsaliyeSiraNo_Specified;
    property ReferansNo:               string      Index (IS_OPTN) read FReferansNo write SetReferansNo stored ReferansNo_Specified;
    property OzelKargoTakipNo:         string      Index (IS_OPTN) read FOzelKargoTakipNo write SetOzelKargoTakipNo stored OzelKargoTakipNo_Specified;
    property Adet:                     Integer     read FAdet write FAdet;
    property BirimDesi:                TXSDecimal  read FBirimDesi write FBirimDesi;
    property BirimKg:                  TXSDecimal  read FBirimKg write FBirimKg;
    property KargoIcerigi:             string      Index (IS_OPTN) read FKargoIcerigi write SetKargoIcerigi stored KargoIcerigi_Specified;
    property KapidanOdemeTahsilatTipi: Byte        read FKapidanOdemeTahsilatTipi write FKapidanOdemeTahsilatTipi;
    property KapidanOdemeTutari:       TXSDecimal  read FKapidanOdemeTutari write FKapidanOdemeTutari;
    property EkHizmetler:              string      Index (IS_OPTN) read FEkHizmetler write SetEkHizmetler stored EkHizmetler_Specified;
    property SevkAdresiAdi:            string      Index (IS_OPTN) read FSevkAdresiAdi write SetSevkAdresiAdi stored SevkAdresiAdi_Specified;
    property TeslimSekli:              Byte        read FTeslimSekli write FTeslimSekli;
    property TasimaSekli:              Byte        read FTasimaSekli write FTasimaSekli;
    property BayiNo:                   string      Index (IS_OPTN) read FBayiNo write SetBayiNo stored BayiNo_Specified;
    property EntegrasyonId:            string      Index (IS_OPTN) read FEntegrasyonId write SetEntegrasyonId stored EntegrasyonId_Specified;
    property EntegrasyonHesaplamaTuru: string      Index (IS_OPTN) read FEntegrasyonHesaplamaTuru write SetEntegrasyonHesaplamaTuru stored EntegrasyonHesaplamaTuru_Specified;
  end;


  // ************************************************************************ //
  // Namespace : http://tempuri.org/
  // soapAction: http://tempuri.org/GonderiyiKargoyaGonder
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : ServiceSoap
  // service   : Service
  // port      : ServiceSoap
  // URL       : http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx
  // ************************************************************************ //
  ServiceSoap = interface(IInvokable)
  ['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
    function  GonderiyiKargoyaGonder(const KullaniciAdi: string; const Sifre: string; const Gonderi: Gonderi): string; stdcall;
  end;

function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ServiceSoap;


implementation
  uses System.SysUtils;

function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
  defWSDL = 'http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx?WSDL';
  defURL  = 'http://www.suratkargo.com.tr/GonderiWebServiceGercek/service.asmx';
  defSvc  = 'Service';
  defPrt  = 'ServiceSoap';
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 ServiceSoap);
    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;


destructor Gonderi.Destroy;
begin
  System.SysUtils.FreeAndNil(FBirimDesi);
  System.SysUtils.FreeAndNil(FBirimKg);
  System.SysUtils.FreeAndNil(FKapidanOdemeTutari);
  inherited Destroy;
end;

procedure Gonderi.SetKisiKurum(Index: Integer; const Astring: string);
begin
  FKisiKurum := Astring;
  FKisiKurum_Specified := True;
end;

function Gonderi.KisiKurum_Specified(Index: Integer): boolean;
begin
  Result := FKisiKurum_Specified;
end;

procedure Gonderi.SetSahisBirim(Index: Integer; const Astring: string);
begin
  FSahisBirim := Astring;
  FSahisBirim_Specified := True;
end;

function Gonderi.SahisBirim_Specified(Index: Integer): boolean;
begin
  Result := FSahisBirim_Specified;
end;

procedure Gonderi.SetAliciAdresi(Index: Integer; const Astring: string);
begin
  FAliciAdresi := Astring;
  FAliciAdresi_Specified := True;
end;

function Gonderi.AliciAdresi_Specified(Index: Integer): boolean;
begin
  Result := FAliciAdresi_Specified;
end;

procedure Gonderi.SetIl(Index: Integer; const Astring: string);
begin
  FIl := Astring;
  FIl_Specified := True;
end;

function Gonderi.Il_Specified(Index: Integer): boolean;
begin
  Result := FIl_Specified;
end;

procedure Gonderi.SetIlce(Index: Integer; const Astring: string);
begin
  FIlce := Astring;
  FIlce_Specified := True;
end;

function Gonderi.Ilce_Specified(Index: Integer): boolean;
begin
  Result := FIlce_Specified;
end;

procedure Gonderi.SetTelefonEv(Index: Integer; const Astring: string);
begin
  FTelefonEv := Astring;
  FTelefonEv_Specified := True;
end;

function Gonderi.TelefonEv_Specified(Index: Integer): boolean;
begin
  Result := FTelefonEv_Specified;
end;

procedure Gonderi.SetTelefonIs(Index: Integer; const Astring: string);
begin
  FTelefonIs := Astring;
  FTelefonIs_Specified := True;
end;

function Gonderi.TelefonIs_Specified(Index: Integer): boolean;
begin
  Result := FTelefonIs_Specified;
end;

procedure Gonderi.SetTelefonCep(Index: Integer; const Astring: string);
begin
  FTelefonCep := Astring;
  FTelefonCep_Specified := True;
end;

function Gonderi.TelefonCep_Specified(Index: Integer): boolean;
begin
  Result := FTelefonCep_Specified;
end;

procedure Gonderi.SetEmail(Index: Integer; const Astring: string);
begin
  FEmail := Astring;
  FEmail_Specified := True;
end;

function Gonderi.Email_Specified(Index: Integer): boolean;
begin
  Result := FEmail_Specified;
end;

procedure Gonderi.SetAliciKodu(Index: Integer; const Astring: string);
begin
  FAliciKodu := Astring;
  FAliciKodu_Specified := True;
end;

function Gonderi.AliciKodu_Specified(Index: Integer): boolean;
begin
  Result := FAliciKodu_Specified;
end;

procedure Gonderi.SetIrsaliyeSeriNo(Index: Integer; const Astring: string);
begin
  FIrsaliyeSeriNo := Astring;
  FIrsaliyeSeriNo_Specified := True;
end;

function Gonderi.IrsaliyeSeriNo_Specified(Index: Integer): boolean;
begin
  Result := FIrsaliyeSeriNo_Specified;
end;

procedure Gonderi.SetIrsaliyeSiraNo(Index: Integer; const Astring: string);
begin
  FIrsaliyeSiraNo := Astring;
  FIrsaliyeSiraNo_Specified := True;
end;

function Gonderi.IrsaliyeSiraNo_Specified(Index: Integer): boolean;
begin
  Result := FIrsaliyeSiraNo_Specified;
end;

procedure Gonderi.SetReferansNo(Index: Integer; const Astring: string);
begin
  FReferansNo := Astring;
  FReferansNo_Specified := True;
end;

function Gonderi.ReferansNo_Specified(Index: Integer): boolean;
begin
  Result := FReferansNo_Specified;
end;

procedure Gonderi.SetOzelKargoTakipNo(Index: Integer; const Astring: string);
begin
  FOzelKargoTakipNo := Astring;
  FOzelKargoTakipNo_Specified := True;
end;

function Gonderi.OzelKargoTakipNo_Specified(Index: Integer): boolean;
begin
  Result := FOzelKargoTakipNo_Specified;
end;

procedure Gonderi.SetKargoIcerigi(Index: Integer; const Astring: string);
begin
  FKargoIcerigi := Astring;
  FKargoIcerigi_Specified := True;
end;

function Gonderi.KargoIcerigi_Specified(Index: Integer): boolean;
begin
  Result := FKargoIcerigi_Specified;
end;

procedure Gonderi.SetEkHizmetler(Index: Integer; const Astring: string);
begin
  FEkHizmetler := Astring;
  FEkHizmetler_Specified := True;
end;

function Gonderi.EkHizmetler_Specified(Index: Integer): boolean;
begin
  Result := FEkHizmetler_Specified;
end;

procedure Gonderi.SetSevkAdresiAdi(Index: Integer; const Astring: string);
begin
  FSevkAdresiAdi := Astring;
  FSevkAdresiAdi_Specified := True;
end;

function Gonderi.SevkAdresiAdi_Specified(Index: Integer): boolean;
begin
  Result := FSevkAdresiAdi_Specified;
end;

procedure Gonderi.SetBayiNo(Index: Integer; const Astring: string);
begin
  FBayiNo := Astring;
  FBayiNo_Specified := True;
end;

function Gonderi.BayiNo_Specified(Index: Integer): boolean;
begin
  Result := FBayiNo_Specified;
end;

procedure Gonderi.SetEntegrasyonId(Index: Integer; const Astring: string);
begin
  FEntegrasyonId := Astring;
  FEntegrasyonId_Specified := True;
end;

function Gonderi.EntegrasyonId_Specified(Index: Integer): boolean;
begin
  Result := FEntegrasyonId_Specified;
end;

procedure Gonderi.SetEntegrasyonHesaplamaTuru(Index: Integer; const Astring: string);
begin
  FEntegrasyonHesaplamaTuru := Astring;
  FEntegrasyonHesaplamaTuru_Specified := True;
end;

function Gonderi.EntegrasyonHesaplamaTuru_Specified(Index: Integer): boolean;
begin
  Result := FEntegrasyonHesaplamaTuru_Specified;
end;

initialization
  { ServiceSoap }
  InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/GonderiyiKargoyaGonder');
  InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap), ioDocument);
  { ServiceSoap.GonderiyiKargoyaGonder }
  InvRegistry.RegisterMethodInfo(TypeInfo(ServiceSoap), 'GonderiyiKargoyaGonder', '',
                                 '[ReturnName="GonderiyiKargoyaGonderResult"]', IS_OPTN);
  RemClassRegistry.RegisterXSClass(Gonderi, 'http://tempuri.org/', 'Gonderi');



end.


Fatura ekranımda ki gönder buttonundaki kodlar

Kod: Tümünü seç


procedure Tfrm_FaturaKaydi.SuratGonderClick(Sender: TObject);
var
Cumle:String;
servis:ServiceSoap;
giden:Gonderi;
XsDec : TxsDecimal;
begin

  Screen.Cursor := crSQLWait;
  try
    servis:= GetServiceSoap(False,'',nil);
    giden:=Gonderi.Create;
    giden.KisiKurum:=qry_faturaCARIUNVAN.Text;
    giden.AliciAdresi:=qry_faturaCARIADRES.Text;
    giden.Il:=qry_faturaIL.Text;
    giden.Ilce:=qry_faturaILCE.Text;
    giden.TelefonCep:=qry_CarilerCEPTEL1.Text;
    giden.AliciKodu:=qry_faturaCARIKOD.Text;
    giden.KargoTuru:=3;
    giden.Odemetipi:=2;
    giden.IrsaliyeSeriNo:='A';
    giden.IrsaliyeSiraNo:=qry_faturaFATURANO.Text;
    giden.OzelKargoTakipNo:=qry_faturaFATURANO.Text;
    giden.Adet:=1;
    XsDec := TXSDecimal.Create;
    XsDec.DecimalString := Format('%f', [StrToFloat(edt_GENELTOPLAM.Text)]);
    giden.KapidanOdemeTutari:=XsDec;
    giden.KapidanOdemeTahsilatTipi:=1;
 
    Cumle:=servis.GonderiyiKargoyaGonder('test','test',giden);
    ShowMessage(Cumle);
  finally
    giden.Free;
    Screen.Cursor := crDefault;
  end;
  
Mücadele güzelleştirir!
ertank
Kıdemli Üye
Mesajlar: 1648
Kayıt: 12 Eyl 2015 12:45

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen ertank »

Merhaba,

Ancak tahmin ediyorum, ihtimal hata sebebi class içindeki tüm parametreleri doldurmadığın için olabilir. Tüm ile kastım doldurulması gereken tüm parametreler. Acaba Soapui uygulaması standart bazı değer atamalarını yapıyor olabilir mi?

Tüm bilgiler arka planda XML'e dönüştürülüp gönderiliyor diye düşünüyorum. Soapui ile gönderilen XML bilgisini network üzerinden gelen/giden paketlerden elde edebilirsen ve kendi uygulamanın gönderdiği XML bilgisini de elde edebilirsen ikisini yan yana kontrol ettiğinde farklılıkları tespit edebileceğine inanıyorum.
Kullanıcı avatarı
greenegitim
Üye
Mesajlar: 713
Kayıt: 28 Nis 2011 10:33
Konum: İstanbul

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen greenegitim »

Hocam mallesef tüm alanları doldurduğum halde aynı hatayı veriyor işin ilginç tarafı php ile yazılmış bir webserviste kodlarda çalışmada hiç bir sıkıntı yok iken burada dotnet ile yazılmış bu serviste bu hatayı veriyor There is an error in XML document (2, 724) buradan gönderdiği xml deki 2. satırda header tagında hata var diye düşünüyorum ama gönderdiğim xml bilgisini nasıl elde edeceğimi bilmiyorum onu araştırıyorum.
Mücadele güzelleştirir!
Kullanıcı avatarı
greenegitim
Üye
Mesajlar: 713
Kayıt: 28 Nis 2011 10:33
Konum: İstanbul

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen greenegitim »

Ne ilginçtirki delphi 7 ile denedim çalıştı delphi 7 ile import edip wizardın oluşturduğu service.pas dosyasını xe10 projemin kodlarının olduğu klasöre alıp onu projeye ekledim şimdi hata vermedi kullanıcı adı şifre yanlış diye servis cevap verdi buraya kadar bile gelemiyordum xe10 da. iki sürümün wizardının oluşturduğu service.pas dosyalarında ufak tefek farklılıklar var ama hangi farklılıktan dolayı çalışmadı test edemedim henüz.
Mücadele güzelleştirir!
Kullanıcı avatarı
greenegitim
Üye
Mesajlar: 713
Kayıt: 28 Nis 2011 10:33
Konum: İstanbul

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen greenegitim »

Güncelleme: HTTPRIO1BeforeExecute olayında

Kod: Tümünü seç

Memo1.Text:=StreamToString(SOAPRequest);
Function

Kod: Tümünü seç

Function StreamToString(Stream: TStream): String;
begin
    with TStringStream.Create('') do
    try
        CopyFrom(Stream, Stream.Size - Stream.Position);
        Result := DataString;
    finally
        Free;
    end;
end;
yazdığımızda gönderdiğimiz xml i görebiliyoruz. ama gönderdiği xml e baktığımda <Il>KOCAELÄ°</Il> türkçe karakter ler bozuk çıkıyor

Kod: Tümünü seç

  HTTPRIO1.HTTPWebNode.UseUTF8InHeader := True;
yaptım
servisin pas dosyasında da

Kod: Tümünü seç

InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
satırı var daha önce karşılan varmı böyle bir durumla?
Mücadele güzelleştirir!
ertank
Kıdemli Üye
Mesajlar: 1648
Kayıt: 12 Eyl 2015 12:45

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen ertank »

Anladığım kadarıyla tüm "string" bilgileri senden UTF8 encoded istiyor. Normalde Delphi 10 UnicodeString kullanır. Bizim kullandığımız "string" arka planda UnicodeString için oluşturulmuş bir "type" tanımlamasıdır. UnicodeString içindeki İ karakteri ile UTF8 string içindeki İ karakteri codepage değerleri farklıdır. Konu ile ilgili "System.UTF8Encode()" ve "System.UTF8Decode()" fonksiyonlarını incelemeni öneriyorum.

Diğer taraftan Delphi 7 çok yüksek ihtimalle Unicode desteği olmadığı için çalışıyor diye düşünüyorum.

Atama yaptığın değerleri önceden UTF8 encode ederek atamayı yapman gerekecek. Ancak senin "Gonderi = class(TRemotable)" içinde UnicodeString tanımlamaların var. Önce bunları düzenlemek gerekli. (Değişiklik öncesi yedek almakta fayda var)

Kod: Tümünü seç

Gonderi = class(TRemotable)
  private
    FKisiKurum: RawByteString;
    FKisiKurum_Specified: boolean;
    FSahisBirim: RawByteString;
    FSahisBirim_Specified: boolean;
    FAliciAdresi: RawByteString;
    FAliciAdresi_Specified: boolean;
    FIl: RawByteString;
    FIl_Specified: boolean;
    FIlce: RawByteString;
    FIlce_Specified: boolean;
    FTelefonEv: RawByteString;
    FTelefonEv_Specified: boolean;
    FTelefonIs: RawByteString;
    FTelefonIs_Specified: boolean;
    FTelefonCep: RawByteString;
    FTelefonCep_Specified: boolean;
    FEmail: RawByteString;
    FEmail_Specified: boolean;
    FAliciKodu: RawByteString;
    FAliciKodu_Specified: boolean;
    FKargoTuru: Byte;
    FOdemetipi: Byte;
    FIrsaliyeSeriNo: RawByteString;
    FIrsaliyeSeriNo_Specified: boolean;
    FIrsaliyeSiraNo: RawByteString;
    FIrsaliyeSiraNo_Specified: boolean;
    FReferansNo: RawByteString;
    FReferansNo_Specified: boolean;
    FOzelKargoTakipNo: RawByteString;
    FOzelKargoTakipNo_Specified: boolean;
    FAdet: Integer;
    FBirimDesi: TXSDecimal;
    FBirimKg: TXSDecimal;
    FKargoIcerigi: RawByteString;
    FKargoIcerigi_Specified: boolean;
    FKapidanOdemeTahsilatTipi: Byte;
    FKapidanOdemeTutari: TXSDecimal;
    FEkHizmetler: RawByteString;
    FEkHizmetler_Specified: boolean;
    FSevkAdresiAdi: RawByteString;
    FSevkAdresiAdi_Specified: boolean;
    FTeslimSekli: Byte;
    FTasimaSekli: Byte;
    FBayiNo: RawByteString;
    FBayiNo_Specified: boolean;
    FEntegrasyonId: RawByteString;
    FEntegrasyonId_Specified: boolean;
    FEntegrasyonHesaplamaTuru: RawByteString;
    FEntegrasyonHesaplamaTuru_Specified: boolean;
    procedure SetKisiKurum(Index: Integer; const Astring: RawByteString);
    function  KisiKurum_Specified(Index: Integer): boolean;
    procedure SetSahisBirim(Index: Integer; const Astring: RawByteString);
    function  SahisBirim_Specified(Index: Integer): boolean;
    procedure SetAliciAdresi(Index: Integer; const Astring: RawByteString);
    function  AliciAdresi_Specified(Index: Integer): boolean;
    procedure SetIl(Index: Integer; const Astring: RawByteString);
    function  Il_Specified(Index: Integer): boolean;
    procedure SetIlce(Index: Integer; const Astring: RawByteString);
    function  Ilce_Specified(Index: Integer): boolean;
    procedure SetTelefonEv(Index: Integer; const Astring: RawByteString);
    function  TelefonEv_Specified(Index: Integer): boolean;
    procedure SetTelefonIs(Index: Integer; const Astring: RawByteString);
    function  TelefonIs_Specified(Index: Integer): boolean;
    procedure SetTelefonCep(Index: Integer; const Astring: RawByteString);
    function  TelefonCep_Specified(Index: Integer): boolean;
    procedure SetEmail(Index: Integer; const Astring: RawByteString);
    function  Email_Specified(Index: Integer): boolean;
    procedure SetAliciKodu(Index: Integer; const Astring: RawByteString);
    function  AliciKodu_Specified(Index: Integer): boolean;
    procedure SetIrsaliyeSeriNo(Index: Integer; const Astring: RawByteString);
    function  IrsaliyeSeriNo_Specified(Index: Integer): boolean;
    procedure SetIrsaliyeSiraNo(Index: Integer; const Astring: RawByteString);
    function  IrsaliyeSiraNo_Specified(Index: Integer): boolean;
    procedure SetReferansNo(Index: Integer; const Astring: RawByteString);
    function  ReferansNo_Specified(Index: Integer): boolean;
    procedure SetOzelKargoTakipNo(Index: Integer; const Astring: RawByteString);
    function  OzelKargoTakipNo_Specified(Index: Integer): boolean;
    procedure SetKargoIcerigi(Index: Integer; const Astring: RawByteString);
    function  KargoIcerigi_Specified(Index: Integer): boolean;
    procedure SetEkHizmetler(Index: Integer; const Astring: RawByteString);
    function  EkHizmetler_Specified(Index: Integer): boolean;
    procedure SetSevkAdresiAdi(Index: Integer; const Astring: RawByteString);
    function  SevkAdresiAdi_Specified(Index: Integer): boolean;
    procedure SetBayiNo(Index: Integer; const Astring: RawByteString);
    function  BayiNo_Specified(Index: Integer): boolean;
    procedure SetEntegrasyonId(Index: Integer; const Astring: RawByteString);
    function  EntegrasyonId_Specified(Index: Integer): boolean;
    procedure SetEntegrasyonHesaplamaTuru(Index: Integer; const Astring: RawByteString);
    function  EntegrasyonHesaplamaTuru_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property KisiKurum:                RawByteString      Index (IS_OPTN) read FKisiKurum write SetKisiKurum stored KisiKurum_Specified;
    property SahisBirim:               RawByteString      Index (IS_OPTN) read FSahisBirim write SetSahisBirim stored SahisBirim_Specified;
    property AliciAdresi:              RawByteString      Index (IS_OPTN) read FAliciAdresi write SetAliciAdresi stored AliciAdresi_Specified;
    property Il:                       RawByteString      Index (IS_OPTN) read FIl write SetIl stored Il_Specified;
    property Ilce:                     RawByteString      Index (IS_OPTN) read FIlce write SetIlce stored Ilce_Specified;
    property TelefonEv:                RawByteString      Index (IS_OPTN) read FTelefonEv write SetTelefonEv stored TelefonEv_Specified;
    property TelefonIs:                RawByteString      Index (IS_OPTN) read FTelefonIs write SetTelefonIs stored TelefonIs_Specified;
    property TelefonCep:               RawByteString      Index (IS_OPTN) read FTelefonCep write SetTelefonCep stored TelefonCep_Specified;
    property Email:                    RawByteString      Index (IS_OPTN) read FEmail write SetEmail stored Email_Specified;
    property AliciKodu:                RawByteString      Index (IS_OPTN) read FAliciKodu write SetAliciKodu stored AliciKodu_Specified;
    property KargoTuru:                Byte        read FKargoTuru write FKargoTuru;
    property Odemetipi:                Byte        read FOdemetipi write FOdemetipi;
    property IrsaliyeSeriNo:           RawByteString      Index (IS_OPTN) read FIrsaliyeSeriNo write SetIrsaliyeSeriNo stored IrsaliyeSeriNo_Specified;
    property IrsaliyeSiraNo:           RawByteString      Index (IS_OPTN) read FIrsaliyeSiraNo write SetIrsaliyeSiraNo stored IrsaliyeSiraNo_Specified;
    property ReferansNo:               RawByteString      Index (IS_OPTN) read FReferansNo write SetReferansNo stored ReferansNo_Specified;
    property OzelKargoTakipNo:         RawByteString      Index (IS_OPTN) read FOzelKargoTakipNo write SetOzelKargoTakipNo stored OzelKargoTakipNo_Specified;
    property Adet:                     Integer     read FAdet write FAdet;
    property BirimDesi:                TXSDecimal  read FBirimDesi write FBirimDesi;
    property BirimKg:                  TXSDecimal  read FBirimKg write FBirimKg;
    property KargoIcerigi:             RawByteString      Index (IS_OPTN) read FKargoIcerigi write SetKargoIcerigi stored KargoIcerigi_Specified;
    property KapidanOdemeTahsilatTipi: Byte        read FKapidanOdemeTahsilatTipi write FKapidanOdemeTahsilatTipi;
    property KapidanOdemeTutari:       TXSDecimal  read FKapidanOdemeTutari write FKapidanOdemeTutari;
    property EkHizmetler:              RawByteString      Index (IS_OPTN) read FEkHizmetler write SetEkHizmetler stored EkHizmetler_Specified;
    property SevkAdresiAdi:            RawByteString      Index (IS_OPTN) read FSevkAdresiAdi write SetSevkAdresiAdi stored SevkAdresiAdi_Specified;
    property TeslimSekli:              Byte        read FTeslimSekli write FTeslimSekli;
    property TasimaSekli:              Byte        read FTasimaSekli write FTasimaSekli;
    property BayiNo:                   RawByteString      Index (IS_OPTN) read FBayiNo write SetBayiNo stored BayiNo_Specified;
    property EntegrasyonId:            RawByteString      Index (IS_OPTN) read FEntegrasyonId write SetEntegrasyonId stored EntegrasyonId_Specified;
    property EntegrasyonHesaplamaTuru: RawByteString      Index (IS_OPTN) read FEntegrasyonHesaplamaTuru write SetEntegrasyonHesaplamaTuru stored EntegrasyonHesaplamaTuru_Specified;
  end;
Class tanımı değiştirildikten sonra artık aşağıdaki gibi kullanabiliriz.

Kod: Tümünü seç

procedure Tfrm_FaturaKaydi.SuratGonderClick(Sender: TObject);
var
  Cumle: String;
  servis: ServiceSoap;
  giden: Gonderi;
  XsDec: TxsDecimal;
begin
  Screen.Cursor := crSQLWait;
  try
    servis := GetServiceSoap(False,'',nil);
    giden := Gonderi.Create();
    giden.KisiKurum := System.UTF8Encode(qry_faturaCARIUNVAN.Text);
    giden.AliciAdresi := System.UTF8Encode(qry_faturaCARIADRES.Text);
    giden.Il := System.UTF8Encode(qry_faturaIL.Text);
    giden.Ilce := System.UTF8Encode(qry_faturaILCE.Text);
    giden.TelefonCep := System.UTF8Encode(qry_CarilerCEPTEL1.Text);
    giden.AliciKodu := System.UTF8Encode(qry_faturaCARIKOD.Text);
    giden.KargoTuru:=3;
    giden.Odemetipi:=2;
    giden.IrsaliyeSeriNo := System.UTF8Encode('A');
    giden.IrsaliyeSiraNo := System.UTF8Encode(qry_faturaFATURANO.Text);
    giden.OzelKargoTakipNo := System.UTF8Encode(qry_faturaFATURANO.Text);
    giden.Adet:=1;
    XsDec := TXSDecimal.Create();
    XsDec.DecimalString := System.UTF8Encode(Format('%f', [StrToFloat(edt_GENELTOPLAM.Text)]));
    giden.KapidanOdemeTutari:=XsDec;
    giden.KapidanOdemeTahsilatTipi:=1;
 
    Cumle:=servis.GonderiyiKargoyaGonder('test','test',giden);
    ShowMessage(Cumle);
  finally
    giden.Free();
    Screen.Cursor := crDefault;
  end;
Umarım bu sorununu çözer.
Kullanıcı avatarı
greenegitim
Üye
Mesajlar: 713
Kayıt: 28 Nis 2011 10:33
Konum: İstanbul

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen greenegitim »

Malesef türkçe karatkter sorununa çözüm olmadı hocam kargo firmasının servisinde de tuhaflık var web panelinden girdiğimiz şifreyi şimdi webservice kabul etmiyor şifreyi değiştirin kem karakter hem rakam hem noktalama olsun dediler yaptık yine sorgulama v.s yapamadık sadece delphi tarafında değil soap ui dede aynı onlardan yanıt bekliyorum şuan. şu türkçe karakter mevzusunuda araştırmaya koyuldum.
Mücadele güzelleştirir!
Kullanıcı avatarı
tuna
Üye
Mesajlar: 300
Kayıt: 07 Tem 2008 04:39
Konum: İstanbul

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen tuna »

Merhaba. Konu baya bi eskide kalmış ama bende şimdi aynı uygulamayı yapmaya çalışıyorum.
Herşeyi yapmama rağmen aşağıdaki hata gelmekte. Acaba siz sorunu çözmüşmüydünüz.

"Server was unable to read request. ---> There is an error in XML document (2, 506). ---> Input string was not in a correct format."
Kullanıcı avatarı
xozcanx
Üye
Mesajlar: 362
Kayıt: 05 Oca 2012 12:55

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen xozcanx »

Merhaba,
işleminizi ıdHTTP.Post metodu ile de gerçekleştirebilirsiniz. Benzer bir servisi bu şekilde kullanıyorum.
Buradan servis yapısı, giriş parametreleri ve dönüş bilgisi hakkında size bilgi veriyor.
Nasibinde varsa, alırsın karıncadan bile ders, Nasibinde yoksa, bütün cihan önüne serilse, sana ters..
Kullanıcı avatarı
xozcanx
Üye
Mesajlar: 362
Kayıt: 05 Oca 2012 12:55

Re: Sürat Kargo Gönderi web servisi

Mesaj gönderen xozcanx »

Siz şu anakadar yaptıklarınızı paylaşın, birlikte ilerleyelim isterseniz.
Nasibinde varsa, alırsın karıncadan bile ders, Nasibinde yoksa, bütün cihan önüne serilse, sana ters..
Cevapla