Ir al contenido


Foto

Web service caracteres raros


  • Por favor identifícate para responder
2 respuestas en este tema

#1 edorantes

edorantes

    Advanced Member

  • Miembros
  • PipPipPip
  • 78 mensajes

Escrito 19 julio 2014 - 03:09

Hola amigos, hace tiempo estuve investigando sobre como consumir un servicio web y me encontre con este tutorial
http://www.delphiacc...te-i-ii-y-iii)/
Segui esos pasos y efectivamente puede crear el servicio web que uso para generar CFDIS, he programado todo la parte de generar
el cfdi y en efectivo me los genera solo que hay un problema cuando mando un caracter como México,Peña etc... el xml y el pdf  que me devuelve el web service
me salen los datos asi M??xivo, Pe??a, he tratado de mandar el UTF8Decode pero no funciona, les dejo mi codigo,uso Delphi 7 y agradezco sus repuestas.

Codigo generado del web service



delphi
  1. // ************************************************************************ //
  2. // The types declared in this file were generated from data read from the
  3. // WSDL File described below:
  4. // WSDL    : http://www.fel.mx/ConexionRemotaCFDI32/ConexionRemota32.asmx?WSDL
  5. //  >Import : http://www.fel.mx/ConexionRemotaCFDI32/ConexionRemota32.asmx?WSDL:0
  6. // Encoding : utf-8
  7. // Version  : 1.0
  8. // (16/11/2012 05:39:10 p.m. - - $Rev: 10138 $)
  9. // ************************************************************************ //
  10.  
  11. unit ConexionRemota32;
  12.  
  13. interface
  14.  
  15. uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns,rio;
  16.  
  17. const
  18.   IS_OPTN = $0001;
  19.   IS_UNBD = $0002;
  20.   IS_NLBL = $0004;
  21.   IS_REF  = $0080;
  22.  
  23.  
  24. type
  25.  
  26.   // ************************************************************************ //
  27.   // The following types, referred to in the WSDL document are not being represented
  28.   // in this file. They are either aliases[@] of other types represented or were referred
  29.   // to but never[!] declared in the document. The types from the latter category
  30.   // typically map to predefined/known XML or Borland types; however, they could also
  31.   // indicate incorrect WSDL documents that failed to declare or import a schema type.
  32.   // ************************************************************************ //
  33.   // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  34.  
  35.  
  36.   ArrayOfString = array of WideString;          { "https://www.fel.mx/ConexionRemotaCFDI"[GblCplx] }
  37.  
  38.   // ************************************************************************ //
  39.   // Namespace : https://www.fel.mx/ConexionRemotaCFDI
  40.   // soapAction: https://www.fel.mx/ConexionRemotaCFDI/%operationName%
  41.   // transport : http://schemas.xmlsoap.org/soap/http
  42.   // style    : document
  43.   // binding  : ConexionRemota32Soap
  44.   // service  : ConexionRemota32
  45.   // port      : ConexionRemota32Soap
  46.   // URL      : http://www.fel.mx/ConexionRemotaCFDI32/ConexionRemota32.asmx
  47.   // ************************************************************************ //
  48.   ConexionRemota32Soap = interface(IInvokable)
  49.   ['{E4A3238C-F777-D8FE-02E9-DAF81F6A193C}']
  50.     function  GenerarCFDIv32(const datosUsuario: ArrayOfString; const datosReceptor: ArrayOfString; const datosCFDI: ArrayOfString; const etiquetas: ArrayOfString; const conceptos: ArrayOfString; const informacionAduanera: ArrayOfString;
  51.                             const retenciones: ArrayOfString; const traslados: ArrayOfString; const retencionesLocales: ArrayOfString; const trasladosLocales: ArrayOfString): ArrayOfString; stdcall;
  52.     function  GenerarCodigoBidimensional(const datosUsuario: ArrayOfString; const UUID: WideString): ArrayOfString; stdcall;
  53.     function  CancelarCFDI(const datosUsuario: ArrayOfString; const ListaACancelar: ArrayOfString): ArrayOfString; stdcall;
  54.     function  EnviarCFDI(const datosUsuario: ArrayOfString; const UUID: WideString; const email: WideString): ArrayOfString; stdcall;
  55.     function  ObtenerPDF(const datosUsuario: ArrayOfString; const UUID: WideString): ArrayOfString; stdcall;
  56.     function  ObtenerNumeroCreditos(const datosUsuario: ArrayOfString): ArrayOfString; stdcall;
  57.   end;
  58.  
  59. function GetConexionRemota32Soap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ConexionRemota32Soap;
  60.  
  61.  
  62. implementation
  63.   uses SysUtils;
  64.  
  65. function GetConexionRemota32Soap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ConexionRemota32Soap;
  66. const
  67.   defWSDL = 'http://www.fel.mx/ConexionRemotaCFDI32/ConexionRemota32.asmx?WSDL';
  68.   defURL  = 'http://www.fel.mx/ConexionRemotaCFDI32/ConexionRemota32.asmx';
  69.   defSvc  = 'ConexionRemota32';
  70.   defPrt  = 'ConexionRemota32Soap';
  71. var
  72.   RIO: THTTPRIO;
  73. begin
  74.   Result := nil;
  75.   if (Addr = '') then
  76.   begin
  77.     if UseWSDL then
  78.       Addr := defWSDL
  79.     else
  80.       Addr := defURL;
  81.   end;
  82.   if HTTPRIO = nil then
  83.     RIO := THTTPRIO.Create(nil)
  84.   else
  85.     RIO := HTTPRIO;
  86.  
  87.  
  88.   try
  89.     Result := (RIO as ConexionRemota32Soap);
  90.     if UseWSDL then
  91.     begin
  92.       RIO.WSDLLocation := Addr;
  93.       RIO.Service := defSvc;
  94.       RIO.Port := defPrt;
  95.     end else
  96.       RIO.URL := Addr;
  97.   finally
  98.     if (Result = nil) and (HTTPRIO = nil) then
  99.       RIO.Free;
  100.   end;
  101. end;
  102.  
  103.  
  104. initialization
  105.   InvRegistry.RegisterInterface(TypeInfo(ConexionRemota32Soap), 'https://www.fel.mx/ConexionRemotaCFDI', 'UTF-8');
  106.   InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ConexionRemota32Soap), 'https://www.fel.mx/ConexionRemotaCFDI/%operationName%');
  107.   InvRegistry.RegisterInvokeOptions(TypeInfo(ConexionRemota32Soap), ioDocument);
  108.   RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'https://www.fel.mx/ConexionRemotaCFDI', 'ArrayOfString');
  109. end.




  • 0

#2 edorantes

edorantes

    Advanced Member

  • Miembros
  • PipPipPip
  • 78 mensajes

Escrito 21 julio 2014 - 10:42

bueno, buscandole lo resolvi, en el


delphi
  1. function GetConexionRemota32Soap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ConexionRemota32Soap;


despues de el


delphi
  1. if HTTPRIO = nil then
  2.     RIO := THTTPRIO.Create(nil)
  3.   else
  4.     RIO := HTTPRIO;



solo tenia que agreagar esta linea


delphi
  1. RIO.HTTPWebNode.UseUTF8InHeader := True;


para que lo mandara como utf8 y reconociera los caractesres


Bueno espero alguien mas si lo ve le ayude, Nos vemos.
  • 0

#3 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4.945 mensajes
  • LocationMéxico

Escrito 21 julio 2014 - 10:46

solo tenia que agreagar esta linea


delphi
  1. RIO.HTTPWebNode.UseUTF8InHeader := True;


para que lo mandara como utf8 y reconociera los caractesres


Bueno espero alguien mas si lo ve le ayude, Nos vemos.


Gracias por compartir la solución.
  • 0




IP.Board spam blocked by CleanTalk.