I need to implement Client SOAP with FWH/XHARBOUR

Post Reply
Vladimir Zorrilla
Posts: 225
Joined: Tue Feb 28, 2006 4:25 pm
Location: PERU

I need to implement Client SOAP with FWH/XHARBOUR

Post by Vladimir Zorrilla »

Friends

This I need to do

http://www.aduanet.gob.pe/aduanas/opera ... rvices.htm


In VFP already this ready one

Web Services from Visual Fox Pro

This example it can find in the following link


http://www.aduanet.gob.pe/js/app/WebSer ... FoxPro.zip

along with lib FoxCrypto.fll

The library FoxCrypto.fll

it contains function that codifies and decodifica in base 64

which allows to the work data type bytes.


Prueba.prg

SET LIBRARY TO FoxCrypto.FLL

PROCEDURE psEnviArchivo

***********************

*send file

PARAMETER pArc

tcInFile = IIF(EMPTY(pArc),"C:\desaprg\prueba\CDDEmbargoM4.htm", pArc)

lcInFile = FILETOSTR(tcInFile)

lcInFile64 = codifica(lcInFile)

***

doc = CreateObject("MSXML2.DOMDocument")

http = CreateObject("MSXML2.XMLHTTP")

http.Open("POST", "http://desweb1:8001/portafolio/portafolio", .F.)

http.SetRequestHeader("SOAPAction", "enviaArchivoWebService")

http.SetRequestHeader("Content-Type", "text/xml")

**load file

xml = fnArmaCadXml("A", "0091", "XXXX", "142", lcInFile64, "CDDEmbargoM5.htm")

doc.LoadXML(xml)

http.Send(doc.xml)

res = CreateObject("MSXML2.DOMDocument")

response = http.responseText

*?response

res.LoadXML(http.responseText)

txt = res.selectSingleNode("//NroEnvioGenerado") &&Return

IF nvl(txt.text,' ') = " " THEN

TXT="ERROR EN WS "

ENDIF

wait window txt.text NOWAIT

*? txt.text

release doc

release http

release res

release response

RETURN

FUNCTION decodifica

PARAMETER pCadena

LOCAL lcBinary, lnHandle, lnSize

lnHandle = Base64DecoderCreate()

IF lnHandle > 0

Base64DecoderPut(lnHandle, pCadena)

Base64DecoderClose(lnHandle)

lnSize = Base64DecoderMaxRetrievable(lnHandle)

lcBinary = Base64DecoderGet(lnHandle, lnSize)

Base64DecoderDestroy(lnHandle)

ELSE

WAIT WIND "ERROR al instanciar"

RETURN .F.

ENDIF

RETURN lcBinary



FUNCTION codifica

PARAMETER pCadena

LOCAL lcBase64, lcInFile, lnHandle, lnSize

lnHandle = Base64EncoderCreate( .T. )

IF lnHandle > 0

Base64EncoderPut(lnHandle, pCadena)

Base64EncoderClose(lnHandle)

lnSize = Base64EncoderMaxRetrievable(lnHandle)

lcBase64 = Base64EncoderGet(lnHandle, lnSize)

Base64EncoderDestroy(lnHandle)

ELSE

WAIT WIND "ERROR al instanciar"

RETURN .F.

ENDIF

RETURN lcBase64



FUNCTION fnArmaCadXml

*********************

PARAMETER pTOpe, pOpe, pClave, pAdu, pArch, pNomArch

strxml = [<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"] + CHR(13)

strxml = strxml + [ xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"] + CHR(13)

strxml = strxml + [ xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"] + CHR(13)

strxml = strxml + [ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">] + CHR(13)

strxml = strxml + [ <env:Header>] + CHR(13)

strxml = strxml + [ </env:Header>] + CHR(13)

strxml = strxml + [ <env:Body>] + CHR(13)

strxml = strxml + [ <m:enviaArchivoWebService xmlns:m="http://www.bea.com/education/webservice ... /javaclass"] + CHR(13)

strxml = strxml + [ env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">] + CHR(13)

strxml = strxml + [ <toperador xsi:type="xsd:string">] + pTOpe + [</toperador>] + CHR(13)

strxml = strxml + [ <operador xsi:type="xsd:string">] + pOpe + [</operador>] + CHR(13)

strxml = strxml + [ <clave xsi:type="xsd:string">] + pClave + [</clave>] + CHR(13)

strxml = strxml + [ <aduana xsi:type="xsd:string">] + pAdu + [</aduana>] + CHR(13)

strxml = strxml + [ <archivoEnvioByte xsi:type="xsd:base64Binary">] + pArch + [</archivoEnvioByte>] + CHR(13)

strxml = strxml + [ <nombreArchivo xsi:type="xsd:string">] + pNomArch+ [</nombreArchivo>] + CHR(13)

strxml = strxml + [ </m:enviaArchivoWebService>] + CHR(13)

strxml = strxml + [ </env:Body>] + CHR(13)

strxml = strxml + [</


Thanks

Vladimir Zorrilla
cps_net@hotmail.com
ME INTERESA FW Y XHB POR SER OPEN SOURCE
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Vladimir,

We are going to review it asap.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply