Forum Discussion

Former_Member's avatar
Former_Member
Ideator I
8 years ago

Upload and download File from vbscript

Last days, i am trying to develop a visual basic script to upload file into vaultserver. I have read previous Post from year 2007, but I have not managed to upload files. Does anyone have a script to upload files using soap? Thanks, Jesús

3 Replies

  • Hello, after some test in Aras  and simulation in Mozzila Firefox Debug, I will try to describe the process to upload file and my problems. In the upload file process, Two web services are involved: Innovator.asp and Vault.asp The Vault is the place where the files will be store, It is composed of several directories, highlighting a directory called .transaction. The transaction folder is a temp folder, it is used to store files temporaly. The process consists of several steps:
    • The first step is to obtain an Id for the file that will be uploaded. This id is obtained by calling the web service Innovator.asp. The SOAPACTION action is <GenerateNewGUID>. Here is an example: <id>69EF0393764C40E18BE2F28F9AD7AED4</id> This id is used to create the tree folder structure to store the file. The next step is oriented to know the Vault web services, the system send a soap message to obtain the vault web service.
    Once the web service address is known, a transaction must be created. A transaction is the process where you get the name of the temporary folder where the file will be uploaded. The transaction id is obtained by a call to vault service like this soap message: <BeginTransaction></BeginTransaction> A example response is: <BeginTransactionResponse><Result>8071a87c0beb77036a52ae0c1961ecc7</Result></BeginTransactionResponse> This id will be used to create a temp folder into .transaction folder. The next step consists of uploading the file. The upload process is not direct transfer to vault, Initially the file is uploaded to temp folder. The upload request must contain a header with the file's id and the transaction among other parameters. The body of message is the file content. For example, i show the header... The result message is empty. SOAPAction: UploadFile AUTHUSER: admin AUTHPASSWORD: 607920b64fe136f9ab2389e371852af2 DATABASE: InnovatorDatabase LOCALE: en-US TIMEZONE_NAME: W. Europe Standard Time VAULTID: 67BBB9204FE84A8981ED8313049BA06C Content-Type: application/octet-stream Content-Range: bytes 0-497/498 Content-Disposition: attachment; filename*=utf-8''aras.txt Aras-Content-Range-Checksum: 1730142698 Aras-Content-Range-Checksum-Type: xxHashAsUInt32AsDecimalString transactionid: 8071a87c0beb77036a52ae0c1961ecc7 ... Content-Length: 498 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache As can be seen, the header shows the transactionid, SOAPACTION is UploadFile and in the fileid parameter is the id obtained from GenerateNewGUID. localhost/.../vaultserver.aspx When the soap Message is send, the system creates a folder with name like transactionid into .transaction temp folder and upload the file. Likewise, the ID file is used to create a directory structure where the file is temporarily stored. For this example: .transaction\8071a87c0beb77036a52ae0c1961ecc7\6\9E\F0393764C40E18BE2F28F9AD7AED4\aras.txt As body message is include the file content, if the file is a txt file i can see the text in the body.... The next step is commit the transaction in vault service. This process is used to create a file itemtype into database and copy the file from temp foldes to definitive folder. The body of soap message is shown: -----------------------------260692838118154 Content-Disposition: form-data; name="XMLData" <SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../"> <SOAP-ENV:Body> <ApplyItem> <Item type="File" id="69EF0393764C40E18BE2F28F9AD7AED4" action="add" loaded="1" levels="1" isTemp="1" LastModifiedOn="1527498621648" typeId="8052A558B9084D41B9F11805E464F443" doGetItem="1"> <filename>aras.txt</filename><checkedout_path/><file_size>498</file_size> <Relationships> <Item type="Located" id="3088ED3F2CCB494F91DFD8C10FA8F267" action="add" loaded="1" levels="0" isTemp="1" typeId="5698BACD2A7A45D6AC3FA60EAB3E6566" LastModifiedOn="1527498621643"> <file_version>1</file_version><source_id keyed_name="">69EF0393764C40E18BE2F28F9AD7AED4</source_id> <related_id keyed_name="Default">67BBB9204FE84A8981ED8313049BA06C</related_id> </Item> </Relationships> <locked_by_id keyed_name="Innovator Admin">30B991F927274FA3829655F50C99472E</locked_by_id> <checksum/> </Item> </ApplyItem> </SOAP-ENV:Body> </SOAP-ENV:Envelope> -----------------------------260692838118154-- The soap message is delimited by a boundary. The boundary is a text string, that It must not be present in the file.It is used as a separator and it must be defined into header. The SOAP message add a file ItemType and a relationships call located. The relatioships between file and vault. The header of this message is: SOAPAction: CommitTransaction AUTHUSER: admin AUTHPASSWORD: 607920b64fe136f9ab2389e371852af2 DATABASE: InnovatorDatabase LOCALE: en-US TIMEZONE_NAME: W. Europe Standard Time VAULTID: 67BBB9204FE84A8981ED8313049BA06C transactionid: 8071a87c0beb77036a52ae0c1961ecc7 ... Content-Length: 1061 Content-Type: multipart/form-data; boundary=---------------------------260692838118154 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache Finally, the system call Innovator webservice to unlock the file....and the process finish. I have tried to launch this process in vbscript but i have some problems. When the upload message is send the systen dont create the temp directories (transaction) but the response message is blank or empty. And the commit message send a error message, that it cant connect to the server... I have some question about the process, for example where is obtained the located id in the commit soap message? This is my research to use vbscript to upload files by soap message. I would be delighted if someone has tried this process or has information that can help me. I think that my fault is in the upload, but i dont know if the upload message is ok.... Thanks, Jesús
  • Using the API iom.dll, it should be something like this
    Dim newFile = innov.newItem("File", "add")
     newFile.setProperty("filename", "myfile")
     newFile.attachPhysicalFile("c:\temp\myfile.txt")
     Dim result = newFile.apply()
  • Thank yo Yoann, By iom.dll i can upload file as you describe, but i am using vbscript and Msxml2.ServerXMLHTTP object... I can send AML operation by SOAP but i don´t know to upload a file. I see that in a post the user used a macro call Rialto, but i can find this document... I would like to upload by soap message, i read post about it, where used multipart html to send the file and AML to create the File Item.