Eu tenho um problema que consiste na comunicação entre uma aplicação cliente (serviço) em VB.NET e um servidor ASP.
A partir da aplicação cliente pretendo enviar um ficheiro XML (ou o seu conteúdo) para o servidor, lá fazer um tratamento de valores e retornar o ficheiro XML para posterior utilização no VB.NET.
O código que estou a tentar fazer dá-me como resposta "Erro: Ficheiro inválido". Naturalmente, o ficheiro XML está bem construído.
Source Code:
SERVER :
My source code in vbscript :
Dim XMLDoc, XMLNode, XMLRoot, XMLErrorParse
Dim sResposta, sValue
Set XMLDoc = Server.CreateObject ("MSXML2.DOMDocument.4.0")
XMLDoc.async=false
XMLDoc.load(Request.BinaryRead(Request.TotalBytes))
set XMLErrorParse = XMLDoc.validate()
if XMLErrorParse.errorCode <> 0 then sResposta="ERROR: Invalid Request." & vbcrlf & XMLErrorParse.errorCode
& ": " & XMLErrorParse.reason
if sResposta = "" then
set XMLRoot=XMLDoc.documentElement
if XMLRoot is nothing then
sResposta = "Invalid XML"
end if
end if
if sResposta="" then
set XMLNode = XMLRoot.selectSingleNode("TAGVALUE")
if XMLNode is nothing then
sResposta="ERROR: Invalid Tag Value (NOTHING)"
else
sValue=XMLNode.Text
if sValue="" then sResposta="ERROR: Empty Tag Value"
end if
end if
if sResposta="" then
sValue = "CORRECT"
else
sValue = sResposta
end if
set XMLNode = XMLRoot.selectSingleNode("RESPONSE")
XMLNode.Text = sValue
Response.ContentType = "text/xml"
XMLdoc.Save Response
CLIENT:
Dim oWebClient as System.Net.WebClient
Dim oFileResp As FileWebResponse
Dim oSentXML As Byte(), oResponseXML As Byte()
Dim sResponseXML As String = ""
Dim cUrl as String = "http://www.abc.pt/file.asp"
oWebClient.Headers.Add("Content-Type", "text/xml")
oSentXML = System.Text.Encoding.ASCII.GetBytes(XMLDocument.OuterXml)
oResponseXML = oWebClient.UploadData(cURL, "POST", oSentXML)
sResponseXML = Convert.ToBase64String(oResponseXML)