Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 22-10-2010
ocram ocram is offline
Miembro
 
Registrado: nov 2006
Posts: 25
Poder: 0
ocram Va por buen camino
Consumir webservice manda variables null

Buenos dias.

Tengo un WebService hecho en .net al cual le paso un numero de habitacion y resort y me devuelve un xml con informacion del huesped, cuando entro directamente desde el explorador de internet y le pongo manualmente la variables funciona perfectamente el problema es que quiero consumir este webservice desde delphi 6 y al momento de ejecutarlo si consume el webservice pero el problema es que le envia null en las variables.

Aqui les dejo el codigo que se creó automaticamente mediante el wizard de delphi:

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/webservice/PMSWebService.asmx?WSDL
// Encoding : utf-8
// Version : 1.0
// (21/10/2010 10:28:12 a.m. - $Revision: 1.9.1.0.1.0.1.9 $)
// ************************************************************************ //

unit PMSWebService;

interface

uses InvokeRegistry, 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.
// ************************************************************************ //
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:string - "http://www.w3.org/2001/XMLSchema"


// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/DatosHuesped
// transport : http://schemas.xmlsoap.org/soap/http
// binding : Service1Soap
// service : Service1
// port : Service1Soap
// URL : http://localhost/webservice/PMSWebService.asmx
// ************************************************************************ //
Service1Soap = interface(IInvokable)
['{CFE467D4-A39E-2BD2-5836-7685A9E27F8D}']
function DatosHuesped(const idResort: Integer; const Habitacion: String): String; stdcall;
end;

function GetService1Soap(UseWSDL: Boolean=System.False; Addr: string=''): Service1Soap;


implementation
uses SOAPHTTPClient;

function GetService1Soap(UseWSDL: Boolean; Addr: string): Service1Soap;
const
defWSDL = 'http://localhost/webservice/PMSWebService.asmx?WSDL';
defURL = 'http://localhost/webservice/PMSWebService.asmx';
defSvc = 'Service1';
defPrt = 'Service1Soap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
RIO := THTTPRIO.Create(nil);
try
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
Result := (RIO as Service1Soap);
finally
if Result = nil then
RIO.Free;
end;
end;


initialization
InvRegistry.RegisterInterface(TypeInfo(Service1Soap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Service1Soap), 'http://tempuri.org/DatosHuesped');

end.



Y AQUI LO QUE HAGO YO PARA TRATAR DE CONSUMIR EL WEB SERVICE, ES UNA FORMA DONDE AGREGO UN HTTPRIO 2 EDIT (UNO PARA # DE RESORT Y OTRO PARA # NUMERO DE HABITACION) Y UN MEMO QUE ES DONDE QUIERO PONER EL XML DEVUELTO.

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Rio, SOAPHTTPClient, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
Button1: TButton;
HTTPRIO1: THTTPRIO;
HTTPRIO2: THTTPRIO;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

USES PMSWebService, ReservationsConsumer;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
res: String;
begin
Memo1.Lines.Text:= (HTTPRIO1 as Service1SoaP).DatosHuesped(StrToInt(Edit1.Text), Edit2.Text);
end;

end.


ENTONCES ESTO SI CONSUME EL WEBSERVICE PERO LAS VARIABLES DE LA FUNCION DATOSHUESPED LOS MANDA COMO NULL

ALGUNA IDEA DE EN QUE ESTOY FALLANDO?


GRACIAS
Responder Con Cita
  #2  
Antiguo 29-10-2010
charlatan charlatan is offline
Registrado
NULL
 
Registrado: oct 2010
Posts: 1
Poder: 0
charlatan Va por buen camino
eso pasa es una pulga del importer, en el archivo generado por el importer nada mas te vas a la parte de inicializacion en la parte de abajo del archivo, en la cual existe una linea parecida a esta.

InvRegistry.RegisterInvokeOptions(TypeInfo(xxx), ioDocument)

esa linea la pones de primera despues del "initialization" y ya funciona
en tu caso no veo esa linea
nada mas agregala en el inicio y remplaza xxx por la interface
queria algo asi

initialization
InvRegistry.RegisterInvokeOptions(TypeInfo(Service1Soap), ioDocument); ///ESTA LINEA AGREGALA
InvRegistry.RegisterInterface(TypeInfo(Service1Soap), URL, 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Service1Soap), OTROURL);

end.

no me deja poner url asi q los cambie para q me dejara postear

Última edición por charlatan fecha: 29-10-2010 a las 20:00:58.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Problema al consumir webservice PHP desde Delphi7 apicito OOP 0 16-03-2010 10:37:43
QReport me manda a imprimir 20,000 hojas El_Raso Impresión 0 23-03-2007 01:41:49
cambiar campo null a not null andressanchez Firebird e Interbase 8 18-09-2006 22:00:09
que necesito para consumir servicios web? jvalles Internet 1 30-03-2005 09:13:28
Problema al consumir un Webservice netcigos Varios 0 08-03-2004 15:09:30


La franja horaria es GMT +2. Ahora son las 21:32:33.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi