WAIT WINDOW 'PROCESANDO'NOWAIT
loConexionCobroPre = CREATEOBJECT( "Microsoft.XMLHTTP" )

cUrl = 'http://localhost/post.php'

cTest = 'Eddy Torres'

TEXT TO cXml  NOSHOW textmerge
<datos>
<<cTest>>
</datos>
ENDTEXT


username = 'user'
lpassword = '1234'
auth = Strconv(username + ":" + lpassword, 13)

&& MSXML2.XMLHTTP.3.0 : https://msdn.microsoft.com/en-us/library/ms535874%28v=vs.85%29.aspx


loConexion.open("POST", cUrl, .F.)
loConexion.setRequestHeader("Content-Type", "application/xml")
loConexion.setRequestHeader("Accept", "application/xml")
*loConexion.setRequestHeader("Authorization", "Basic " + auth)

&& Envío:
loConexion.send(cXml)

&& Respuesta:

&& Status 200: OK, 401: Problemas de autenticación
loStatus = loConexion.status
&& XML de respuesta:
loResponse = loConexion.responseText
?STR(loStatus) + loResponse

&& Va a cambiar a 201
IF loStatus = 200
	
	oXML = CREATEOBJECT('MSXML2.DomDocument')
	oXML.ASYNC = .F.
	oXml.loadXML(loResponse)		
	oRootNode 	= oXML.documentElement
	
	oNodeList = oRootNode.getElementsByTagName("result")
	oNode = oNodeList.ITEM(0)
	loResult	= oNode.firstChild.nodeValue
	
	oNodeList = oRootNode.getElementsByTagName("errorCodeId")
	oNode = oNodeList.ITEM(0)
	loErrorCodeId	= oNode.firstChild.nodeValue
	
	
	IF loResult = '1'
		
	ELSE 
		MESSAGEBOX("Resultado " + loResult + "; errorCodeId " + loErrorCodeId)
	ENDIF	

ELSE 
	
	MESSAGEBOX('Error ' + STR(loStatus))

ENDIF





