• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Member
    Posts: 4
    Registered: ‎04-11-2012
    Accepted Solution

    Preferred method of obtaining DocumentService?

    132 Views, 2 Replies
    04-11-2012 06:08 AM

    Hi,

     

    I'm exploring the Vault 2012 SDK and I've come across the following effective code (not exactly the same code, however the same effective code) to obtain the DocumentService in the "VaultList" sample:

    Dim serverName As String = "localhost"
    Dim vaultName As String = "Vault"
    Dim userName As String = "Administrator"
    Dim password As String = ""
    
    Dim secSrv As SecurityService = New SecurityService()
    secSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.SecuritySvc.SecurityHeader
    secSrv.Url = "http://" + serverName + "/AutodeskDM/Services/SecurityService.asmx"
    
    secSrv.SignInReadOnly(userName, password, vaultName)
    
    Dim docSrv As DocumentService = New DocumentService()
    docSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader
    docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId
    docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket
    docSrv.Url = "http://" + serverName + "/AutodeskDM/Services/DocumentService.asmx"
    
    Dim login As UserPasswordCredentials = New UserPasswordCredentials(serverName, vaultName, userName, password)
    
    Dim serviceManager As New WebServiceManager(login)
    Dim root As Folder = docSrv.GetFolderRoot()
    ' more code here...

     However, the "VaultFileBrowser" has the following effective code:

    Dim serverName As String = "localhost"
    Dim vaultName As String = "Vault"
    Dim userName As String = "Administrator"
    Dim password As String = ""
    
    Dim login As UserPasswordCredentials = New UserPasswordCredentials(serverName, vaultName, userName, password)
    
    Dim serviceManager As New WebServiceManager(login)
    Dim docSrv As DocumentService = serviceManagaer.DocumentService
    Dim root As Folder = docSrv.GetFolderRoot()
    ' more code here...

    Which method is the preferred method of obtaining the DocumentService object? The method in "VaultFileBrowser" looks much cleaner. The only educated guess I can make for the method in "VaultList" is the use of the "SignInReadOnly" method. What are the disadvantages of the "VaultFileBrowser" method?

     

    Kind regards,

    Dave.

    Please use plain text.
    Member
    Posts: 4
    Registered: ‎04-11-2012

    Re: Preferred method of obtaining DocumentService?

    04-11-2012 06:18 AM in reply to: dajvid

    Hi,

     

    I've done a little more experimenting and found the following simplification of the effective code in "VaultList":

     

    Dim serverName As String = "localhost"
    Dim vaultName As String = "Vault"
    Dim userName As String = "Administrator"
    Dim password As String = ""
    
    Dim secSrv As SecurityService = New SecurityService()
    secSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.SecuritySvc.SecurityHeader
    secSrv.Url = "http://" + serverName + "/AutodeskDM/Services/SecurityService.asmx"
    
    secSrv.SignInReadOnly(userName, password, vaultName)
    
    Dim docSrv As DocumentService = New DocumentService()
    docSrv.SecurityHeaderValue = New Autodesk.Connectivity.WebServices.DocumentSvc.SecurityHeader
    docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId
    docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket
    docSrv.Url = "http://" + serverName + "/AutodeskDM/Services/DocumentService.asmx"
    
    Dim root As Folder = docSrv.GetFolderRoot()
    ' more code here...

    The "VaultList" example does create a WebServiceManager object, however it seems redundant to operation of the "VaultList" project itself and I can successfully remove this object and still have this example run.

     

    Which method is better?

     

    Kind regards,

    Dave.

    Please use plain text.
    Employee
    Daniel.Dulzo
    Posts: 61
    Registered: ‎05-25-2011

    Re: Preferred method of obtaining DocumentService?

    04-11-2012 07:21 AM in reply to: dajvid

    Hello Dave,

     

    Both code examples are valid ways of signing in to Vault and initializing the various web services with proper security headers. As you've mentioned, using the web service manager is a little bit cleaner and it also provides some other benefits such as automatic re-sign in if your connection is invalidated. More information can be found here in Doug's blog post on JustOnesAndZeros.



    Daniel Dulzo
    Software Engineer
    Autodesk, Inc.
    Please use plain text.