Communication with the Vault server takes the form of SOAP commands over HTTP. As you may know, SOAP is XML data, and XML is text. Does that mean the program you wrote uploads and downloads files as text data?
By default, the answer is yes, your program converts files to text when transferring files. This can be a big performance problem if your program has to upload thousands of files. The conversion to base64 eats up CPU cycles and increases the transfer size by about 30%.
Setting up your project
If you want to transfer your files in binary mode, there are several steps you need to go through:
- Download and install Microsoft Web Service Extensions (WSE) 3.0. You can find it on the Microsoft site. (I'd post a direct link, but they keep changing it).
- If you are using Visual Studio 2005, select the "Integrate with Visual Studio" option during the install.
- In your project, create a reference to Microsoft.Web.Services3.
- If you are using Vault 2012 or higher, skip to step 8.
- Generate your web services.
- If you are using Visual Studio 2008 there are some extra steps:
- In the Solution Explorer, activate the Show All Files option.
- Expand the web reference and locate the Reference.cs (or Reference.vb) file and open it.
- Change the base class of the Service object from "System.Web.Services.Protocols.SoapHttpClientProtocol" to "Microsoft.Web.Services3.WebServicesClientProtocol"
- (optional) Add Wse to the end of the class name and constructor.
- Repeat as needed for the other web services. However most people just fix up the Document Service.
- In your code, use the web service classes with "Wse" at the end.
- Create an app.config XML file if your project does not already have one.
- Merge in the following XML:
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<maxMessageLength value="51200" />
<mtom clientMode="On" />
- When you build your project, app.config gets renamed to [EXE name].config. Make sure you deploy this with your application.
- You are done.
Gee, that's a lot of steps. If any of them are not done property, the system will automatically revert to text transfer of your files. So how do test things to make sure that files are being transferred as binary data?
UPDATE: There is a tool called Fiddler which provides a better way to test than the technique below. See this article for instructions on how to test using Fiddler.
Here is the approach I use. It's not very good. If you find a better way, please let me, and everybody else, know in the comments section.
The basic principle is to have IIS log the bytes transferred and see if that matches the size of a file that you upload or download with your application.
- Open up your IIS manager on your Vault server machine.
Note: I'm using IIS 5. Things may be different depending on your version.
- Select the web site running Vault.
- Right click and select Properties.
- Go to the Web Site tab.
- Check the Enable Logging box.
- Click on the Properties button.
- Go to the Extended Properties tab.
- Check the Extended Properties box.
- Check the Bytes Sent and Bytes Received boxes.
- Click OK on the dialogs.
- Find a file that is at least 10 MB large.
- Upload the file to Vault using your application. Or add it to Vault and download it using your application.
- Go to the IIS log and open it. (ex. C:\WINDOWS\system32\Logfiles\W3SVC1\ex100316.log)
- You should see an entry to DocumentService.asmx that has a large number of bytes transferred. For example:
20:28:02 127.0.0.1 POST /AutodeskDM/Services/DocumentService.asmx 200 2675 14074058
- If that large number is about the size of the uploaded file, then things work. Otherwise something is not working right and you will need to double check your application.
In my case, 14,074,058 is close to the size of the file I uploaded (14,068,867). The IIS log will always be slightly higher due to HTTP and SOAP headers.
If you want to deliberately break things to test the negative case, you can do this easily without even needing to re-compile. Just edit your .config file and set the <mtom> clientMode setting to "Off". Upload or download the file again and check the file size in the IIS log. It should be significantly bigger. For example, my test showed 18,763,057 as the transfer size, which is 33% larger than the file.