HI All,
I am currently working on a project in which i need to post a file to webservice using vbscript.
The webservice method is PutFile(buffer).This method create a file and put the content received in that file.
I am trying to read a file in binary format and trying post the binary text to webservice.
As i am new to this domain i am not sure how can i do it.
Following is the code i am trying
Const adTypeText =1
Dim folderIdx, objFilesystem, objFilestream, intFilelength
folderIdx = "D:\sample.txt"
Set objFilesystem = CreateObject("Scripting.FileSystemObject")
Set objFilestream = objFilesystem.GetFile(folderIdx)
intFilelength = objFilestream.size
WScript.Echo intFileLength
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = adTypeText
BinaryStream.Open
BinaryStream.LoadFromFile folderIdx
ReadTextFile =BinaryStream.Read
Dim xmlhttp,objHttp
set xmlhttp = Createobject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", "http://localhost/WebApplication1/Service1.asmx/PutFile", False
xmlhttp.setRequestHeader "Content-Type","application/x-www-form-urlencoded" '"text/html"
xmlhttp.setRequestHeader "Content-Length", intFilelength
xmlhttp.setOption 2, 13056
xmlhttp.send(ReadTextFile)
Nothing will be happening using this.
Can anybody help me how this can be done.
Thanks in advance,
Nars