
The service manager concept has been around for a while. Almost every SDK and blog sample has one. For Vault 2012, we decided to build it into the API. It's a bit tricky to get used to at first. But once you get the hang of it, you'll love it.
WebServiceManager features:
- Login management – It will handle the login and logout for you so you don't have to.
- Service creation – The WebServiceManager is a factory, so it will create all your services for you. You don't have to worry about calling new, setting the URL or copying security headers.
- Re-SignIn – If you run into error 300, which means your login has been invalidated, the WebServiceManager will automatically catch the error, sign-in again, re-run the command, and return the new result. This feature is only available if you use a credentials class that supports sign in.
How to use
The WebServiceManager can be found in Autodesk.Connectivity.WebServicesTools.dll. As the name implies, it contains tools to help you use the web services. Currently, the WebServiceManager is the main component of the DLL.
To create a WebServiceManager, you need to provide it with credentials, which tells the manager how to log in and log out of Vault. There are several credentials classes available, so you need to use the appropriate one. It usually is based on the information you have available. For example, if you have the username and password, you would use the UserPasswordCredentials. If you are in a custom command, and a context is passed in, you can use the UserIdTicketCredentials.
NOTE: There are some known issues with UserIdTicketCredentials and WebServiceCredentials, so read this article first before using.
Once you have created your WebServiceManager, you are ready to start making web service calls. It has properties for each service and each service has its full set of functions.
To sign out, just let WebServiceManager go out of scope. It's an IDisposable class, which means it does special things before it gets garbage collected. So that's where all the sign out happens if a sign out is needed. I recommend declaring the WebServiceManager in a using statement if possible. That way you know when Dispose() will get called. If it doesn't make sense to have a using statement, I recommend explicitly calling Dispose() when you are done with it. In effect, the Dispose() replaces SignOut().
Since the WebServiceManager references every service, which in turn references every server function, the WebServiceManager is the web services API. You can just use a single object to make every Vault server call.
Sample code:
Here is a comparison of the old way versus the new way with the WebServiceManager.
|
DocumentService docSrv = new DocumentService(); secSrv.SignOut(); |
|
UserPasswordCredentials login = using (WebServiceManager serviceManager = |
|
Dim secSrv As SecurityService = New SecurityService() Dim docSrv As DocumentService = New DocumentService() Dim root As Folder = docSrv.GetFolderRoot() secSrv.SignOut() |
|
dim login As UserPasswordCredentials = _ Using serviceManager As New WebServiceManager(login) |

Leave a Reply