FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#11
|
|||
|
|||
Tengo Respuesta
1). Con el WSDL Importer, darle la direccion del WS, para mi caso :
https://e-beta.sunat.gob.pe/ol-ti-it...llService?wsdl se genera la unidad billService1.pas la cual contiene la siguiente funcion GetbillService, ojo segun las versiones de delphi estas cambian en D7 y D2007 no se soportan los InvRegistry.RegisterParamInfo, si quieres generar un billService para versiones antiguas marca la opcion TXSxxxx for simple nillable, asi se genera un billservice capaz de usarse en versiones anteriores, yo estoy usando XE4 y bueno ahora D10.1 Berlin, esto de los webservices es mejor hacerlo con versiones nuevas, aunque las antiguas generan ejecutables mas rapidos. 2). Utilizar billservice1.pas Para mi caso hay securidad ws-token, asi que para implementar la cabecera donde enviar el usuario y clave use THTTPReqResp En un boton poner el siguiente codigo, ojo para la SUNAT peru, nos responde con un zip dentro del cual esta un xml con la respuesta si el documento ha sido aceptado o no, el archivo tiene que ser cargado en un array de bytes asi que lineas mas abajo te dejo los procedure que use. Aun no termino el proyecto, ahora con wireshark estoy examinando como viajan los paquetes hacia el servidor, con la finalidad de ver si cumplen con el estandar que solicita SUNAT, cuando lo tengo listo lo libero hubelsolis@hotmail.com procedure TForm1.Button1Click(Sender: TObject); const defWSDL = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl'; defURL = 'https://e-beta.sunat.gob.pe:443/ol-ti-itcpfegem-beta/billService'; defSvc = 'billService'; defPrt = 'BillServicePort'; var tBillServ : billService; Archivo : String; Envio : TByteDynArray; Respuesta : TByteDynArray; HTTPReqResp1: THTTPReqResp; HTTPRIO1 : THTTPRIO; begin HTTPReqResp1 := THTTPReqResp.create(nil); HTTPReqResp1.Password := 'moddatos'; HTTPReqResp1.username := '20489697042MODDATOS'; HTTPRIO1 := THTTPRIO.Create(nil); HTTPRIO1.HTTPWebNode := HTTPReqResp1; HTTPRIO1.WSDLLocation := defWSDL; HTTPRIO1.Service := defSvc; HTTPRIO1.Port := defPrt; // levanto el servicio tBillServ:=GetbillService(TRUE,'',HTTPRIO1); Archivo:='20489697042-03-BB01-00000003.ZIP'; envio:= FileToByteArray('D:\'+Archivo); // envio try respuesta:=tBillServ.sendBill(Archivo,envio); except on E : Exception do ShowMessage(E.ClassName+' error raised, with message : '+E.Message); end; ByteArrayToFIle(respuesta, 'D:\respuestas\rptab.zip' ); end; procedure ByteArrayToFIle(const ByteArray : TByteDynArray; const FileName : string ); var Count : integer; F : FIle of Byte; pTemp : Pointer; begin AssignFile( F, FileName ); Rewrite(F); try Count := Length( ByteArray ); pTemp := @ByteArray[0]; BlockWrite(F, pTemp^, Count ); finally CloseFile( F ); end; end; function FIleToByteArray( const FileName : string ) : TByteDynArray; const BLOCK_SIZE=1024; var BytesRead, BytesToWrite, Count : integer; F : FIle of Byte; pTemp : Pointer; begin AssignFile( F, FileName ); Reset(F); try Count := FileSize( F ); SetLength(Result, Count ); pTemp := @Result[0]; BytesRead := BLOCK_SIZE; while (BytesRead = BLOCK_SIZE ) do begin BytesToWrite := Min(Count, BLOCK_SIZE); BlockRead(F, pTemp^, BytesToWrite , BytesRead ); pTemp := Pointer(LongInt(pTemp) + BLOCK_SIZE); Count := Count-BytesRead; end; finally CloseFile( F ); end; end; |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
Web services y ws-security | adebonis | Internet | 7 | 15-05-2015 01:54:54 |
Error "Message part {URL}Método was not recognized" al consumir servicio Web Java | Al González | Delphi para la web | 0 | 02-05-2013 08:23:24 |
Web Security de Microsoft | juanjose | Varios | 1 | 03-03-2012 12:32:06 |
Al consumir Servicio Web JAVA el array regresa vacio | guacasoft73 | Varios | 1 | 15-05-2011 06:25:45 |
|