by cdmmaui » Mon Apr 16, 2012 3:30 pm
Dear Otto,
I have created the following code, however I am not get getting the response from the destination. Can you tell me what I am doing wrong?
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function _XmlPost()
local loHyperlink := TOLEAuto():New( "Microsoft.XmlHttp" )
local cXML
local cURL
local cCreate := ""
// Init...
cCreate := LEFT( DTOS( DATE() ), 4 ) + "-" + SUBSTR( DTOS( DATE() ), 5, 2 ) + "-" + RIGHT( DTOS( DATE() ), 2 ) + "T" + TIME() + ".0Z"
cEvent := DTOS( CTOD( "04/10/2012" ) )
cTime := "11:06:53"
cOffset := "-06:00"
cBiz1 := "0614141"
cPo := "987654321"
cXml := [<?xml version="1.0" encoding="UTF-8" standalone="yes"?>]
cXml += [<epcis:EPCISDocument ]
cXml += [xmlns:epcis="urn:epcglobal:epcis:xsd:1" ]
cXml += [xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ]
cXml += [creationDate="] + cCreate + [" ]
cXml += [schemaVersion="1">]
cXml += [<EPCISBody>]
cXml += [<EventList>]
cXml += [<TransactionEvent>]
cXml += [<eventTime>]
cXml += LEFT( cEvent, 4 ) + "-" + SUBSTR(cEvent,5,2) + "-" + RIGHT( cEvent, 2 )
cXml += "T"
cXml += cTime
cXml += cOffset
cXml += [</eventTime>]
cXml += [<eventTimeZoneOffset>]
cXml += cOffset
cXml += [</eventTimeZoneOffset>]
cXml += [<bizTransactionList>]
cXml += [<bizTransaction]
cXml += [ type="urn:epcglobal:demo:btt:po">]
cXml += [urn:epcglobal:demo:bti:po:] + cBiz1 + "." + cPo
cXml += [</bizTransaction>]
cXml += [</bizTransactionList>]
cXml += [<epcList>]
FOR nX1=1 TO 6
cXml += [<epc>]
cXml += [urn:epc:id:giai:] + cBiz1 + "." + STR(nX1,1)
cXml += [</epc>]
NEXT nX1
cXml += [</epcList>]
cXml += [<action>]
cXml += [ADD]
cXml += [</action>]
cXml += [</TransactionEvent>]
cXml += [</EventList>]
cXml += [</EPCISBody>]
cXml += [</epcis:EPCISDocument>]
// temp...
hHan = FCREATE( cBiz1 + ".XML", 0 )
IF (hHan == -1)
MsgWait( "Error Creating " + cBiz1 + ".XML", Ptitle, 1 )
ELSE
FWRITE( hHan, cXml )
FCLOSE( hHan )
MsgWait( cBiz1 + ".XML Created", Ptitle, 1 )
ENDIF
cURL := "http://epcis.allumis.com:8080/epcis-repository-0.5.0/capture"
//cURL := "http://199.188.244.226:8080/epcis-repository-0.5.0/capture"
TRY
loHyperlink:Open( "POST", cURL, .f. )
loHyperlink:setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
cxml := "xml=" + cxml
loHyperlink:Send(cXML )
CATCH
MsgAlert( "Error Transmitting XML", Ptitle )
END
if (At( "SUCCESS", upper(loHyperlink:responseText )) < 5)
MsgWait( cUrl + cEol + "XML Response = " + CRLF + loHyperlink:responseText, Ptitle, 5)
USE epcis
APPEND BLANK
epcis->response := UPPER( loHyperlink:responseText )
epcis->date := DATE()
epcis->time := TIME()
else
MsgWait( Cutl + cEol + "Error", Ptitle, 10 )
endif
DbCloseAll()
RETURN (.T.)