Ver Mensaje Individual
  #1  
Antiguo 16-04-2012
Avatar de lbidi
lbidi lbidi is offline
Miembro
 
Registrado: oct 2003
Ubicación: Montevideo- URUGUAY
Posts: 417
Reputación: 21
lbidi Va por buen camino
Consumir un Web Service

Estimados.

Necesito enviar cierta informacion a un web service de otro sistema desarrollado por otra gente.
Me dieron el archivo wsdl el cual he logrado importar con el wizard y me ha la creado unidad correspondiente.

Aparentemente es muy sencillo, tiene solo una funcion para recibir los datos que yo le debo
enviar. He logrado que compile pero no estoy seguro si el archivo estaba bien o si la unidad
que genero esta bien, porque no he podido acceder a su funcion desde otra unidad de mi sistema.

He leido el post de egostar sobre Web services , pero aun asi no he podido hacer que funcionara.

Les dejo el codigo de la unidad que genero el wizard a ver si alguien puede decirme si lo genero
bien o como debo llamar desde mis otras unidades a la funcion que aqui se hace presente.

Código Delphi [-]

unit u_webService;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_NLBL = $0004;
  IS_UNQL = $0008;
  IS_ATTR = $0010;
  IS_TEXT = $0020;

type

  resultado = interface(IInvokable)
  ['{E215B04D-08B9-A9EF-456D-7550D58C4D38}']

// esta es la funcion que debo utililzar
    function  altaresult(const ErNumLin: Int64; const ResuNumLin: Integer; const ResuDsc: WideString;    const ResuUni: WideString; const ResuVRef: WideString; const ResuVHallado: WideString;
                         const ResuObs: WideString): Integer; stdcall;

  end;

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

implementation
  uses SysUtils;

function Getresult(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): resultado;
const
  defWSDL = 'C:\result.wsdl';
  defURL  = 'http://10.5.1.1:8080/WebServiceEstu/services/result';
  defSvc  = 'resultService';
  defPrt  = 'result';
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 resultado);
    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(resultado), 'http://logica', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(resultado), '');
  InvRegistry.RegisterInvokeOptions(TypeInfo(resultado), ioDocument);

end.

Se supone que debo utilizar esa funcion y pasarle parametros que el "bendito" web service esta
esperando. Ademas no lo puedo probar, ya que la ip en la cual escucha, esta en mi cliente,
y no se puede acceder desde el exterior.

Se agradece eternamente cualquier ayuda y/o sugerencia.

Saludos.
Responder Con Cita