Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Preferred method of obtaining DocumentService?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
dajvid
967 Views, 3 Replies

Preferred method of obtaining DocumentService?

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.

3 REPLIES 3
Message 2 of 4
dajvid
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.

Message 3 of 4
Daniel.Dulzo
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.
Message 4 of 4

Hello Guys,

 

i want to reopen this discussion again, iam not able to get access to the Vault Api via Webservices especially with ASP.NET Core

 

i added the AuthService.svc and the DocumentService.svc Interface to my WCF Connected Services.

 

I created a new authClient, but iam not able to create a new Securityheader or get the Securityheader which is needed in the SignInAsync method, and for alle other webservice methods.

 

Can somone give me a short snippet how i can create a new Securtiyheader with my login creds?

 

Thank you very much.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report