Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Error en componente HTTPRIO (https://www.clubdelphi.com/foros/showthread.php?t=89889)

jlrdz 24-02-2016 18:31:48

Error en componente HTTPRIO
 
Saludos a todos, desde hace días tengo un problema al tratar de consumir un Web Service el cual utilizo el componente THTTPRIO para hacer el llamado, ya importé el wsdl y me genera la Unit del servicio sin problema, tengo configurado las propiedades del componente, WSDLLocation, Service, Port...

Al momento de dar clic sobre el botón que me ejecuta el procedimiento me sale el error:

DTD is Prohibited
Line 1: <!DOCTYPE ...

Ya busqué en varios foros sobre este tema y me he revuelto, encontré la siguiente variable global que puse en False y el error continua:

Código Delphi [-]
function
TMSDOMDocument.GetMSDocument: IXMLDOMDocument;
begin
 Result := MSNode as IXMLDOMDocument;  

  if Result is IXMLDOMDocument2
  then

     (Result as IXMLDOMDocument2).ProhibitDTD := False;
end;

Actualmente no estoy usando algún componente TXMLDocument o algo que use la respuesta como XML, desconozco si tenga que hacerlo asi,
lo unico que tengo declarado es lo siguiente:

Código Delphi [-]
var
  resultadosF:Resultados; //Arreglo de resultado
  resultadoF :Resultado;
  l, i:Integer;
begin


    resultadosF := (HTTPRIO1 as MIWebServicePortType).ConsultaUsuario('usuario','password');

  l := Length(resultadosF);
  Memo1.Lines.Clear;

  for i := 0 to (l - 1) do begin
    resultadoF := resultadosF[i];

    Memo1.Lines.Add('Id: ' + IntToStr(resultadoF.Id));
    Memo1.Lines.Add('Mensaje: ' + resultadoF.msg);

  end;

end;

El proyecto lo estoy desarrollando con Delphi XE8, el mismo web service lo he consumido con otras herramientas y no da problema, una de ellas es la extensión para google chrome que se llama Boomerang, me regresa la información correcta y sin problemas, el service esta hecho con PHP y la libreria NUSOAP.

Espero por favor puedan ayudarme y de antemano muchas gracias por tomarse el tiempo de leer.
Saludos.

bitbow 24-02-2016 18:38:27

Debes revisar las unidades donde se define la interface con el webservice, las que se generan al importar el wsdl, si es posible publica el codigo para que podamos apoyarte mejor.

Saludos.

jlrdz 25-02-2016 00:38:29

Cita:

Empezado por bitbow (Mensaje 502581)
Debes revisar las unidades donde se define la interface con el webservice, las que se generan al importar el wsdl, si es posible publica el codigo para que podamos apoyarte mejor.

Saludos.

Gracias por tu respuesta amigo, aquí publico el Unit que me genera al usar el wizard para importar el wsdl.

Saludos.

Código Delphi [-]
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://localhost/monitor/index.php/PruebaWS?wsdl
//  >Import : http://localhost/monitor/index.php/PruebaWS?wsdl>0
// Encoding : ISO-8859-1
// Version  : 1.0
// (24/02/2016 05:30:33 p.m. - - $Rev: 56641 $)
// ************************************************************************ //

unit PruebaWS;

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 Embarcadero 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"[Gbl]
  // !:int             - "http://www.w3.org/2001/XMLSchema"[Gbl]

  Resultado            = class;                 { "http://localhost/monitor/index.php?/PruebaWS/"[GblCplx] }

  Resultados = array of Resultado;              { "http://localhost/monitor/index.php?/PruebaWS/"[GblCplx] }


  // ************************************************************************ //
  // XML       : Resultado, global, 
  // Namespace : http://localhost/monitor/index.php?/PruebaWS/
  // ************************************************************************ //
  Resultado = class(TRemotable)
  private
    Fid: Integer;
    Fmsg: string;
  published
    property id:  Integer  read Fid write Fid;
    property msg: string   read Fmsg write Fmsg;
  end;


  // ************************************************************************ //
  // Namespace : urn:PruebaWS
  // soapAction: urn:http://localhost/monitor/index.php?/...operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : rpc
  // use       : encoded
  // binding   : PruebaWSBinding
  // service   : PruebaWS
  // port      : PruebaWSPort
  // URL       : http://localhost/monitor/index.php/PruebaWS
  // ************************************************************************ //
  PruebaWSPortType = interface(IInvokable)
  ['{0165AD64-F0D9-9910-7FFC-A13240734C57}']
    function  ConsultaUsuario(const username: string; const password: string): Resultados; stdcall;
    function  ValidaDato(const username: string; const password: string; const identificador: string): Resultados; stdcall;
  end;

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


implementation
  uses SysUtils;

function GetPruebaWSPortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): PruebaWSPortType;
const
  defWSDL = 'http://localhost/monitor/index.php/PruebaWS?wsdl';
  defURL  = 'http://localhost/monitor/index.php/PruebaWS';
  defSvc  = 'PruebaWS';
  defPrt  = 'PruebaWSPort';
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 PruebaWSPortType);
    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
  { PruebaWSPortType }
  InvRegistry.RegisterInterface(TypeInfo(PruebaWSPortType), 'urn:PruebaWS', 'ISO-8859-1');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(PruebaWSPortType), 'urn:http://localhost/monitor/index.php?/...onName%');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Resultados), 'http://localhost/monitor/index.php?/PruebaWS/', 'Resultados');
  RemClassRegistry.RegisterXSClass(Resultado, 'http://localhost/monitor/index.php?/PruebaWS/', 'Resultado');

end.

ElKurgan 25-02-2016 07:37:54

tu no estas usando ningún XML, pero si el web service tiene definidos los campos dentro de un TDT entonces intentará cargarlo al abrir el WS.

¿Es un WS creado por ti? ¿Es uno creado por otros?

Normalmente, si el servicio tiene extensión "wsdl" se puede abrir con el navegador de Internet y ahí te muestra los archivos que utiliza para la validación, incluido cualquier tdt.

Si no, ¿podrías compartirlo con el grupo para que le echemos un vistazo?

Saludos

jlrdz 25-02-2016 17:28:34

Cita:

Empezado por ElKurgan (Mensaje 502619)
tu no estas usando ningún XML, pero si el web service tiene definidos los campos dentro de un TDT entonces intentará cargarlo al abrir el WS.

¿Es un WS creado por ti? ¿Es uno creado por otros?

Normalmente, si el servicio tiene extensión "wsdl" se puede abrir con el navegador de Internet y ahí te muestra los archivos que utiliza para la validación, incluido cualquier tdt.

Si no, ¿podrías compartirlo con el grupo para que le echemos un vistazo?

Saludos


Gracias por tu respuesta ElKurgan, y sí, el ws lo hice yo, este es el wsdl.
Código PHP:

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://localhost/monitor/index.php?/PruebaWS/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost/monitor/index.php?/PruebaWS/">
<
types>
<
xsd:schema targetNamespace="http://localhost/monitor/index.php?/PruebaWS/">
<
xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<
xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
<
xsd:complexType name="Resultado">
<
xsd:all>
<
xsd:element name="id" type="xsd:int"/>
<
xsd:element name="msg" type="xsd:string"/>
</
xsd:all>
</
xsd:complexType>
<
xsd:complexType name="Resultados">
<
xsd:complexContent>
<
xsd:restriction base="SOAP-ENC:Array">
<
xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:Resultado[]"/>
</
xsd:restriction>
</
xsd:complexContent>
</
xsd:complexType>
</
xsd:schema>
</
types>
<
message name="ConsultaUsuarioRequest">
<
part name="username" type="xsd:string"/>
<
part name="password" type="xsd:string"/>
</
message>
<
message name="ConsultaUsuarioResponse">
<
part name="return" type="tns:Resultados"/>
</
message>
<
message name="ValidaDatoRequest">
<
part name="username" type="xsd:string"/>
<
part name="password" type="xsd:string"/>
<
part name="identificador" type="xsd:string"/>
</
message>
<
message name="ValidaDatoResponse">
<
part name="return" type="tns:Resultados"/>
</
message>
<
portType name="PruebaWSPortType">
<
operation name="ConsultaUsuario">
<
documentation>Valida usuario en sistema.</documentation>
<
input message="tns:ConsultaUsuarioRequest"/>
<
output message="tns:ConsultaUsuarioResponse"/>
</
operation>
<
operation name="ValidaDato">
<
documentation>Valida dato emitido.</documentation>
<
input message="tns:ValidaDatoRequest"/>
<
output message="tns:ValidaDatoResponse"/>
</
operation>
</
portType>
<
binding name="PruebaWSBinding" type="tns:PruebaWSPortType">
<
soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<
operation name="ConsultaUsuario">
<
soap:operation soapAction="urn:http://localhost/monitor/index.php?/PruebaWS/ConsultaUsuario" style="rpc"/>
<
input>
<
soap:body use="encoded" namespace="urn:PruebaWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</
input>
<
output>
<
soap:body use="encoded" namespace="urn:PruebaWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</
output>
</
operation>
<
operation name="ValidaDato">
<
soap:operation soapAction="urn:http://localhost/monitor/index.php?/PruebaWS/ValidaDato" style="rpc"/>
<
input>
<
soap:body use="encoded" namespace="urn:PruebaWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</
input>
<
output>
<
soap:body use="encoded" namespace="urn:PruebaWS" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</
output>
</
operation>
</
binding>
<
service name="PruebaWS">
<
port name="PruebaWSPort" binding="tns:PruebaWSBinding">
<
soap:address location="http://localhost/monitor/index.php/PruebaWS"/>
</
port>
</
service>
</
definitions


ElKurgan 29-02-2016 10:54:58

Perdona que haya tardado tanto en contestar. No tengo PHP ni la librería que comentas, pero he creado un webservice (más o menos) como el tuyo desde Delphi XE7 y no me ha dado ningún problema.

¿Es posible que sea la librería la que internamente esté indicando que haya que cargar algún archivo y que se nos pase por alto?

Ya te digo, haciendo todos los pasos en el propio Delphi no da ningún problema.


La franja horaria es GMT +2. Ahora son las 15:03:30.

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