Fórum ClientDataSet exibindo dados de uma página XML #289993
29/07/2005
0
Tenho que desenvolver uma aplicação CLIENT em Delphi 7 que acesse um WEBSERVICE feito em Java. O resultado é retornado em XML. Eu tenho que pegar este XML e apenas mostrá-lo em um DbGrid ou fazer um relatório simples que eu acredito que deva ser feito com um ClientDataSet.
Por favor me ajudem, quais objetos eu devo usar e quais propriedades deles eu devo configurar. Só pra facilitar aqui está um dos links deste WEBSERVICE que está funcionando:
https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws?method=listaCedulas&matricula=58242&cpf=63049635134
Não sei quais objetos devo usar?
Obrigado pela sua atenção,
Pablo.
pablo_ribeiro@hotmail.com
Pablo.ribeiro
Curtir tópico
+ 0Posts
29/07/2005
Elter.teodoro
unit UCedulasPeriodos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, DB, DBClient, SOAPConn, Rio, SOAPHTTPClient,
StdCtrls, ComCtrls, ExtCtrls, IdBaseComponent, IdAntiFreezeBase,
IdAntiFreeze;
type
TForm1 = class(TForm)
HTTPRIO1: THTTPRIO;
SoapConnection1: TSoapConnection;
IdAntiFreeze1: TIdAntiFreeze;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
ConsCedulasPeriodos1;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
FlistaCedulas , FlistaCedulasP : string ;
begin
Screen.Cursor := crHourGlass ;
Button1.Enabled := False ;
Application.ProcessMessages ;
GetConsCedulasPeriodos(False,´https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws´,HTTPRIO1);
Edit1.text := GetConsCedulasPeriodos.listaCedulas( ´1005´ ,´0383864409´ );
Edit2.text := GetConsCedulasPeriodos.listaCedulasP(´1005´ ,´0383864409´,15 );
Screen.Cursor := crDefault ;
Button1.Enabled := True ;
end;
end.
dfm do arquivo UCedulasPeriodos:
object FormCedulasPeriodos: TFormCedulasPeriodos
Left = 454
Top = 200
Width = 545
Height = 380
Caption = ´WebService CedulasPeriodos´
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = ´MS Sans Serif´
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 24
Top = 96
Width = 56
Height = 13
Caption = ´listaCedulas´
end
object Label2: TLabel
Left = 24
Top = 128
Width = 63
Height = 13
Caption = ´listaCedulasP´
end
object Button1: TButton
Left = 127
Top = 165
Width = 75
Height = 25
Caption = ´Consultar´
TabOrder = 0
OnClick = Button1Click
end
object Edit1: TEdit
Left = 104
Top = 88
Width = 313
Height = 21
TabOrder = 1
Text = ´Edit1´
end
object Edit2: TEdit
Left = 104
Top = 120
Width = 289
Height = 21
TabOrder = 2
Text = ´Edit2´
end
object HTTPRIO1: THTTPRIO
WSDLLocation = ´https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws?wsdl´
Service = ´ConsCedulasPeriodosService´
Port = ´ConsCedulasPeriodos´
HTTPWebNode.Agent = ´Borland SOAP 1.2´
HTTPWebNode.UseUTF8InHeader = True
HTTPWebNode.InvokeOptions = [soIgnoreInvalidCerts, soAutoCheckAccessPointViaUDDI]
Converter.Options = [soSendMultiRefObj, soTryAllSchema, soRootRefNodesToBody, soCacheMimeResponse, soUTF8EncodeXML]
Left = 256
Top = 40
end
object IdAntiFreeze1: TIdAntiFreeze
Left = 204
Top = 40
end
object SoapConnection1: TSoapConnection
Agent = ´Borland SOAP 1.2´
Connected = True
URL = ´https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws´
SOAPServerIID = ´IAppServerSOAP - {C99F4735-D6D2-495C-8CA2-E53E5A439E61}´
UseSOAPAdapter = True
Left = 304
Top = 40
end
end
arquivo de importacao dos parametros e funcoes :
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws?wsdl
// Encoding : UTF-8
// Version : 1.0
// (29/07/2005 18:22:24 - 1.33.2.5)
// ************************************************************************ //
unit ConsCedulasPeriodos1;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
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 Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - ´http://www.w3.org/2001/XMLSchema´
// !:int - ´http://www.w3.org/2001/XMLSchema´
// ************************************************************************ //
// Namespace : http://DefaultNamespace
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : ConsCedulasPeriodosSoapBinding
// service : ConsCedulasPeriodosService
// port : ConsCedulasPeriodos
// URL : https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws
// ************************************************************************ //
ConsCedulasPeriodos = interface(IInvokable)
[´{EBBD35D9-689B-2CD9-29D2-EF9AEBCD2D07}´]
function listaCedulas(const matricula: WideString; const cpf: WideString): WideString; stdcall;
function listaCedulasP(const matricula: WideString; const cpf: WideString; const periodo: Integer): WideString; stdcall;
end;
function GetConsCedulasPeriodos(UseWSDL: Boolean=System.False; Addr: string=´´; HTTPRIO: THTTPRIO = nil): ConsCedulasPeriodos;
implementation
function GetConsCedulasPeriodos(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ConsCedulasPeriodos;
const
defWSDL = ´https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws?wsdl´;
defURL = ´https://aplic-corp.mt.gov.br/axis/ConsCedulasPeriodos.jws´;
defSvc = ´ConsCedulasPeriodosService´;
defPrt = ´ConsCedulasPeriodos´;
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 ConsCedulasPeriodos);
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
InvRegistry.RegisterInterface(TypeInfo(ConsCedulasPeriodos), ´http://DefaultNamespace´, ´UTF-8´);
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ConsCedulasPeriodos), ´´);
end.
Gostei + 0
29/07/2005
Elter.teodoro
Edit1.text := GetConsCedulasPeriodos.listaCedulas( ´1005´ ,´0383864409´ );
Edit2.text := GetConsCedulasPeriodos.listaCedulasP(´1005´ ,´0383864409´,15 );
Gostei + 0
29/07/2005
Pablo.ribeiro
Muito obrigado, vc me ajudou muito, valeu cara.
Só mais uma coisa, eu tenho que mostrar este resultado que vem em XML em um DBGrid ou em um relatório tbém. Como ligo este resultado XML em um ClientDataSet, ou seria outro objeto? Eu ligo este ClientDataSet com o SoapConnection através da propriedade RemoteServer, mas e a propriedade ProviderName? como eu ligo, pois qdo eu tento abrir o ClientDataSet ele diz ´Missing Data Provider or data packet´. Saberia como resolvo isto?
Mais uma vez, obrigado pela tua atenção.
Pablo.
Gostei + 0
29/07/2005
Pablo.ribeiro
Muito obrigado, vc me ajudou muito, valeu cara.
Só mais uma coisa, eu tenho que mostrar este resultado que vem em XML em um DBGrid ou em um relatório tbém. Como ligo este resultado XML em um ClientDataSet, ou seria outro objeto? Eu ligo este ClientDataSet com o SoapConnection através da propriedade RemoteServer, mas e a propriedade ProviderName? como eu ligo, pois qdo eu tento abrir o ClientDataSet ele diz ´Missing Data Provider or data packet´. Saberia como resolvo isto?
Mais uma vez, obrigado pela tua atenção.
Pablo.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)