Web Serviceden gelen [CData] nasıl kullanılır

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
adelphiforumz
Üye
Mesajlar: 602
Kayıt: 01 Nis 2008 05:38
Konum: İstanbul

Web Serviceden gelen [CData] nasıl kullanılır

Mesaj gönderen adelphiforumz »

S.A.

Delphi2007 kullanıyorum
Vademecum test SOAP Web servisinden bir veri çekiyorum fakat gelen veri "<Value><![CDATA............" türünde
bu türü delphi2007 de nasıl işleyip ekranda gösterebilirim.

WEB Servis Adresi
http://test-webservice.vademecumonline. ... mecum.wsdl

VademecumBinding altındaki
GetProductDetails fonksiyonu

REQUEST:

Kod: Tümünü seç

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vad="http://test-webservice.vademecumonline.com.tr/Vademecum">
   <soapenv:Header/>
   <soapenv:Body>
      <vad:GetProductDetails>
         <product>
            <id>6834</id>
         </product>
      </vad:GetProductDetails>
   </soapenv:Body>
</soapenv:Envelope>
RESPONSE:

Kod: Tümünü seç

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://test-webservice.vademecumonline.com.tr/Vademecum">
   <SOAP-ENV:Body>
      <ns1:GetProductDetailsResponse>
         <productDetailArray>
            <ProductDetail>
               <Name>Dikkat</Name>
               <Value><![CDATA[<p>Kısa süreli tedavide kullanılır. Aktif gastrointestinal ülser, gastrointestinal ülser veya dispepsi hikayesi, gastrointestinal kanama, Crohn hastalığı, ülseratif kolit, şiddetli kardiyak ve hepatik yetmezlik, şiddetli-orta şiddetli böbrek yetmezliği, hemorajik diatez, pıhtılaşma bozukluğu, gebeliğin 3. trimesteri, laktasyon ve antikoagülan tedavisi görenlerde kontrendikedir. Aspirin veya diğer NSAİ ilaçların astım, bronkospazm, rinit, ürtiker ve anjionörotik ödeme neden olduğu hastalarda kullanılmamalıdır. Alerji hikayesi olanlarda dikkatli kullanılmalıdır. Diüretik tedavisi görenlerde ve hipovolemik olabilecek hastalarda dikkatle kullanılmalıdır. Anne sütüne geçip geçmediği bilinmemektedir. Yüksek doz salisilat, oral antikoagülanlar, lityum, metotreksatla birlikte kullanılmamalıdır. Diüretikler, ACE inhibitörleri, pentoksifilin, zidovudin ve düşük molekül ağırlıklı heparin ile birlikte kullanılırken dikkatli olunmalıdır. Bulantı, kusma, abdominal ağrı, diyare, dispepsi gibi yan etkiler görülebilir.</p>
<p><i>Pediatri:</i> Ampul ve tablet formları 18 yaşından küçüklerde kullanılmaz.</p>]]></Value>
            </ProductDetail>
            <ProductDetail>
               <Name>Doz</Name>
               <Value><![CDATA[<b >Film tablet:</b> Ağrının cinsine ve şiddetine göre genellikle her 4-6 saatte bir 12.5 mg veya 8 saatte bir 25 mg önerilir. Günlük toplam doz 75 mg’ı geçmemelidir. 

<p ><i >Pediatri:</i> 18 yaşından küçüklerde kullanılmamalıdır.</p>

<p ><i >Geriatri:</i> Yaşlılarda tedaviye en düşük dozla (günde 50 mg) başlanmalıdır.</p>

<p ><b >Ampul:</b> IM veya IV uygulanabilir. Önerilen doz, 8-12 saatte bir 50 mg'dır. Günlük maks. doz olan 150 mg'ı geçmemek şartıyla 6 saat arayla uygulanabilir. Kullanma süresi maks. 2 gündür. </p>

<p ><i >Pediatri:</i> 18 yaşından küçüklerde kullanılmamalıdır.</p>

<p ><i >Geriatri:</i> Yaşlılarda tedaviye en düşük dozla (günde 50 mg) başlanmalıdır.</p>]]></Value>
            </ProductDetail>
            <ProductDetail>
               <Name>Endikasyon</Name>
               <Value><![CDATA[Analjezik, antipiretik ve antienflamatuar etkili NSAİ ilaçtır. 

<p ><b >Film tablet:</b> Erişkinlerde kas-iskelet sistemi ağrıları, dismenore ve diş ağrılarının semptomatik tedavisinde endikedir. </p>

<b >Ampul:</b> Oral kullanımın uygun olmadığı postoperatif ağrı, renal kolik ve bel ağrısı gibi orta ve şiddetli ağrıların semptomatik tedavisinde kullanılır.]]></Value>
            </ProductDetail>
         </productDetailArray>
      </ns1:GetProductDetailsResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Teşekkürler
Ehil olmayanlara sabretmek ehil olanları parlatır.
Akıllı birisinden gelen cefa, bilgisizlerin vefasından iyidir.
Bilgiye ulaştı mı ayak, kanat olur
Biz insanı kıyafetiyle ağırlar bilgisiyle uğurlarız.
Mevlana
varyemez
Üye
Mesajlar: 262
Kayıt: 01 Oca 2009 11:00
Konum: Bursa
İletişim:

Re: Web Serviceden gelen [CData] nasıl kullanılır

Mesaj gönderen varyemez »

Dikkat edersen o kısım tamamen html kodlarıyla dolu. Olduğu gibi alıp webbrowser da kullanabilirsin xhtml olarak. ancak bu sefer de Türkçe karakterler başını ağrıtacaktır.. Veya html tag larından arındırıp düz metin olarak da kullanabilirsin
Kullanıcı avatarı
adelphiforumz
Üye
Mesajlar: 602
Kayıt: 01 Nis 2008 05:38
Konum: İstanbul

Re: Web Serviceden gelen [CData] nasıl kullanılır

Mesaj gönderen adelphiforumz »

S.A.

Benim sorunun XML olarak veri delphiye gelmiyor
bu yüzden delphinin import içerisinde gelen text şeklinde veri geliyor

bir örnek yapı kurdum bunun üzerinden yardımcı olabileceklere şimdiden teşekkürler

Import Wsdl link
http://test-webservice.vademecumonline. ... mecum.wsdl

Kod: Tümünü seç

object FrmVademecumTest: TFrmVademecumTest
  Left = 0
  Top = 0
  Caption = 'FrmVademecumTest'
  ClientHeight = 300
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object btnGetProductDetails: TButton
    Left = 12
    Top = 54
    Width = 211
    Height = 25
    Caption = 'GetProductDetails (Eksik kalan)'
    TabOrder = 0
    OnClick = btnGetProductDetailsClick
  end
  object btnGetAllProduct: TButton
    Left = 10
    Top = 18
    Width = 213
    Height = 25
    Caption = 'GetAllProduct (Calisan)'
    TabOrder = 1
    OnClick = btnGetAllProductClick
  end
  object Panel1: TPanel
    Left = 12
    Top = 98
    Width = 603
    Height = 189
    Caption = 'Panel1'
    TabOrder = 2
  end
end

Kod: Tümünü seç

unit UntVademecumTest;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,
  Wsdl_Vademecum_Test,
  Grids, StdCtrls,
  SOAPHTTPClient, ExtCtrls;

  const
  VDC_WDSL_TEST = 'http://test-webservice.vademecumonline.com.tr/vademecum.wsdl';
  VDC_Service = 'VademecumService';
  VDC_Port_Standart           = 'StandartPort';
  VDC_Port_Vademecum          = 'VademecumPort';

type
  TFrmVademecumTest = class(TForm)
    btnGetProductDetails: TButton;
    btnGetAllProduct: TButton;
    Panel1: TPanel;
    procedure btnGetAllProductClick(Sender: TObject);
    procedure btnGetProductDetailsClick(Sender: TObject);
  private
    { Private declarations }
  function fn_Standart_GetAllProduct():TStringGrid;
  function fn_Vademecum_GetProductDetails(_pIdProduct:Int64):TStringGrid;
  public
    { Public declarations }
  end;

var
  FrmVademecumTest: TFrmVademecumTest;

implementation

{$R *.dfm}

function TFrmVademecumTest.fn_Standart_GetAllProduct():TStringGrid;
var
  _SL : TStringGrid;
  _HTTPRIO : THTTPRIO;
  _StandartPort  : StandartPort;
  _GetAllProduct : DescribedProductArray;
  _bSwc:Boolean;
  i, rwc:Integer;
begin
    {$REGION '.....'}
    try
        _bSwc := False;

        _HTTPRIO := THTTPRIO.Create(nil);
        _HTTPRIO.Port := VDC_Port_Standart;
        _HTTPRIO.Service := VDC_Service;

        Application.ProcessMessages;
        try
            _StandartPort  :=  Wsdl_Vademecum_Test.GetStandartPort(False, '', _HTTPRIO);
        except on E: Exception do
          begin
            Exit;
          end;
        end;

        Application.ProcessMessages;
        try
            _GetAllProduct := _StandartPort.GetAllProducts();
        except on E: Exception do
          begin
            Exit;
          end;
        end;

        Application.ProcessMessages;
        _SL := TStringGrid.Create(Self);
        _SL.Parent := Panel1;
        _SL.Align := alClient;
        for i := 0 to _SL.ColCount - 1 do
          _SL.Cols[i].Clear;
        _SL.ColCount := 17;
        _SL.RowCount := 1;
        _SL.Cells[1, 0] := 'RecId';
        _SL.Cells[2, 0] := 'Id';
        _SL.Cells[3, 0] := 'Name';
        _SL.Cells[4, 0] := 'Barcode';
        _SL.Cells[5, 0] := 'NFC';
        _SL.Cells[6, 0] := 'PublicNumber';
        _SL.Cells[7, 0] := 'SGKCode';
        _SL.Cells[8, 0] := 'Exportation';
        _SL.Cells[9, 0] := 'IdCompany';
        _SL.Cells[10,0] := 'IdPrescription';
        _SL.Cells[11,0] := 'CommercialForm_Amount';
        _SL.Cells[12,0] := 'CommercialForm_Unit';
        _SL.Cells[13,0] := 'IdPharmaceuticalForm';
        _SL.Cells[14,0] := 'DayToExcretion';
        _SL.Cells[15,0] := 'ShelfLife_Value';
        _SL.Cells[16,0] := 'ShelfLife_Unit';
        _SL.Cells[17,0] := 'IdDrugForm';

        for I := 0 to Length(_GetAllProduct) - 1 do
        begin
            rwc := _SL.RowCount + 1;
            _SL.RowCount := rwc;
            _SL.Cells[1,rwc-1] := IntToStr(i+1);
            _SL.Cells[2,rwc-1] := IntToStr(_GetAllProduct[i].Id);
            _SL.Cells[3,rwc-1] := _GetAllProduct[i].Name_;
            _SL.Cells[4,rwc-1] := _GetAllProduct[i].Barcode;
            _SL.Cells[5,rwc-1] := _GetAllProduct[i].NFC;
            _SL.Cells[6,rwc-1] := _GetAllProduct[i].PublicNumber;
            _SL.Cells[7,rwc-1] := _GetAllProduct[i].SGKCode;
            _SL.Cells[8,rwc-1] := BoolToStr(_GetAllProduct[i].Exportation);
            _SL.Cells[9,rwc-1] := IntToStr(_GetAllProduct[i].Company.id);
            _SL.Cells[10,rwc-1] := IntToStr(_GetAllProduct[i].Prescription.id);
            _SL.Cells[11,rwc-1] := _GetAllProduct[i].CommercialForm.Amount.DecimalString;
            _SL.Cells[12,rwc-1] := _GetAllProduct[i].CommercialForm.Unit_;
            _SL.Cells[13,rwc-1] := IntToStr(_GetAllProduct[i].CommercialForm.PharmaceuticalForm.id);
            _SL.Cells[14,rwc-1] := IntToStr(_GetAllProduct[i].DayToExcretion);
            _SL.Cells[15,rwc-1] := IntToStr(_GetAllProduct[i].ShelfLife.Value);
            _SL.Cells[16,rwc-1] := _GetAllProduct[i].ShelfLife.Unit_;
            _SL.Cells[17,rwc-1] := IntToStr(_GetAllProduct[i].DrugFormId);
        end;
        _bSwc := True;
    except on E: Exception do
      _bSwc := False;
    end;

    if _bSwc = True then
      Result := _SL
    else
      Result := nil;
    {$ENDREGION}
end;

function TFrmVademecumTest.fn_Vademecum_GetProductDetails(_pIdProduct:Int64):TStringGrid;
var
  _SL : TStringGrid;
  _HTTPRIO : THTTPRIO;
  _VademecumPort  : VademecumPort;
  _GetProductDetails : ProductDetailArray;
  _Product:Product;
  _Text : Wsdl_Vademecum_Test.Text;
  _Paragraph : Paragraph;
  _bSwc:Boolean;
  i, rwc:Integer;
begin
    {$REGION '.....'}
    try
        _bSwc := False;

        _HTTPRIO := THTTPRIO.Create(nil);
        _HTTPRIO.Port := VDC_Port_Vademecum;
        _HTTPRIO.Service := VDC_Service;

        Application.ProcessMessages;
        try
            _VademecumPort  :=  Wsdl_Vademecum_Test.GetVademecumPort(False, '', _HTTPRIO);
        except on E: Exception do
          begin
            Exit;
          end;
        end;

        Application.ProcessMessages;
        try
            _Product := Product.Create();
            _Product.id := _pIdProduct;
            _GetProductDetails := _VademecumPort.GetProductDetails(_Product);
        except on E: Exception do
          begin
            Exit;
          end;
        end;

        Application.ProcessMessages;
        _SL := TStringGrid.Create(Self);
        _SL.Parent := Panel1;
        _SL.Align := alClient;
        for i := 0 to _SL.ColCount - 1 do
          _SL.Cols[i].Clear;
        _SL.ColCount := 17;
        _SL.RowCount := 1;
        _SL.Cells[1, 0] := 'RecId';
        _SL.Cells[2, 0] := 'Name';
        _SL.Cells[3, 0] := 'Value';
        _SL.ColWidths[3] := 300;

        for I := 0 to Length(_GetProductDetails) - 1 do
        begin
            rwc := _SL.RowCount + 1;
            _SL.RowCount := rwc;
            _SL.Cells[1,rwc-1] := IntToStr(i+1);
            _SL.Cells[2,rwc-1] := _GetProductDetails[i].Name_;
            _SL.Cells[3,rwc-1] := 'Bu kısmada Value içindeki değer nasıl alınıp gösterilecek.';

        end;
        _bSwc := True;
    except on E: Exception do
      _bSwc := False;
    end;

    if _bSwc = True then
      Result := _SL
    else
      Result := nil;
    {$ENDREGION}
end;

procedure TFrmVademecumTest.btnGetProductDetailsClick(Sender: TObject);
begin
  fn_Vademecum_GetProductDetails(6834);
end;

procedure TFrmVademecumTest.btnGetAllProductClick(Sender: TObject);
begin
  fn_Standart_GetAllProduct();

end;

end.
Ehil olmayanlara sabretmek ehil olanları parlatır.
Akıllı birisinden gelen cefa, bilgisizlerin vefasından iyidir.
Bilgiye ulaştı mı ayak, kanat olur
Biz insanı kıyafetiyle ağırlar bilgisiyle uğurlarız.
Mevlana
Cevapla