issue with web service connection

issue with web service connection

steven_t_gunderson
Contributor Contributor
2,355 Views
5 Replies
Message 1 of 6

issue with web service connection

steven_t_gunderson
Contributor
Contributor

i am working on updating an add-in created for 2015r2 vault client to use in 2020 vault client. the basic function that is not working is UpdateFileLifeCycleStates(). the add-in does many search functions with the logged in vault user (windows authentication) and then needs to do the lifecycle update with a different user's credentials(vault user). i have verified the connection is being made but it feels like it is instantly being disconnected. im wondering if there is an issue with holding two connections at the same time.

 

im not very familiar with c# or or the SDK. the app was developed by someone else. below i will try to show the logins for both connections and the specific call that is failing

 

normal user log in. i believe the connection is grabbed at application launch and then can be connected again as needed with GetConnection()

 

        public void OnLogOn(IApplication app)
        {
            _vault = app;
            m_conn = app.Connection;
            VaultBridge.Instance.Initialize();
        }

        public void GetConnection()
        {
            if(_vault == null)
                return;
            if(m_conn == null)
                m_conn = _vault.Connection;
        }

web service login. used to make the state change. gets server and vault from normal login and user name and pass from a config file. i tested explicitly entering the strings instead and it works the same. included is the old connection that was used in 2015 that i commented out. i have used authflags for standard and server license with no success. note that the code uses Vlt instead of VDT.vault but the call is the same.

 

 

            string sSvr = VaultExtension.m_conn.Server;
            string sVlt = VaultExtension.m_conn.Vault;
            string sUsr = Settings.Instance().GetConfigVal("VaultUser");
            string sPW = Settings.Instance().GetConfigVal("VaultPW");

            //ACWT.UserPasswordCredentials cred = new ACWT.UserPasswordCredentials(sSvr, sVlt, sUsr, sPW, false);

            //ACWT.WebServiceManager mgr = new ACWT.WebServiceManager(cred);
            //VaultExtension.myAdminConnection = new Vlt.Currency.Connections.Connection(mgr, sUsr, sPW, sVlt, 0, sSvr, 0);
Vlt.Results.LogInResult results = Vlt.Library.ConnectionManager.LogIn(sSvr, sVlt, sUsr, sPW, Vlt.Currency.Connections.AuthenticationFlags.ServerLicense, null); Vlt.Currency.Connections.Connection myAdminConnection = null; if (results.Success) myAdminConnection = results.Connection;

and finally the call to update the lifecycle.

 

 

VaultExtension.myAdminConnection.WebServiceManager.DocumentServiceExtensions.UpdateFileLifeCycleStates(new long[] { f.MasterId }, new long[] { relState }, "Prepared for release by - Vault Release Management Utility.");

 

 

i really cant figure out why the call to update lifecycle is failing with System.NullReferenceException every single time.

 

i promoted my vault account to the special level of admin created for the state change account and used UpdateFileLifeCycleStates() with my connection (replaced myadminconnection with m_conn) and it works fine. can anyone confirm or deny that it is possible to connect to the vault with two different methods and two different users from the same application? can anyone give me a quick way to verify the admin connection is working? i put a watch on the results.success and it was coming back true. i just have no way to know how long that connection is being held. is there something i need to do to the server to allow webservice connections that i didn't do? i logged in with the username and password directly and it can log into the vault client.

 

i tried to force a reconnection just before the lifecycle change because i thought something might have disconnected the admin connection while the searching was going on. it connected again (results.success = true) and went null again before it could change states.

 

any suggestions or questions are appreciated. i have been fighting this for maybe a week and i'm not getting anywhere.

0 Likes
Accepted solutions (1)
2,356 Views
5 Replies
Replies (5)
Message 2 of 6

Markus.Koechl
Autodesk
Autodesk

I am sorry reading that you spent a lot of time already. To avoid this in the future, I recommend reading these help chapters before planning an update jumping several releases: Vault 2020 API changes and Legacy Changes.

There are several changes that you need to take into account, like user credentials and log on.

The logon is best to review in the 2020 SDK template API Onboarding - Console Application. This snippet highlights the essential changes in licensing: valid options are LicensingAgent.None/Client/Server

#region ConnectToVault
            ServerIdentities mServerId = new ServerIdentities();
            mServerId.DataServer = "serveraddress or name";           //replace value by command line args[i]
            mServerId.FileServer = "serveraddress or name";
            string mVaultName = "my Vault Name";
            string mUserName = "Administrator";
            string mPassword = "";
            LicensingAgent mLicAgent = LicensingAgent.Server;
            WebServiceManager mVault = null;
            UserPasswordCredentials mCred = null;

            try
            {
                mCred = new UserPasswordCredentials(mServerId, mVaultName, mUserName, mPassword, mLicAgent);
                mVault = new WebServiceManager(mCred);
.....

Another chapter to read carefully is the Help - Knowledge Base article "Clic Licensing with the Vault SDK".

Hope this helps.

 



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 6

steven_t_gunderson
Contributor
Contributor

i implemented the above with the same results. the connection initializes just fine but the connection is null before i am able to use it. i even made a separate doc service extensions object using the admin web service manager to call update file lifecycle states, thinking that the other object that was previously defined was still using the other user's credentials.

 

...
try
            {
                mCred = new ACWT.UserPasswordCredentials(mServerId, sVlt, sUsr, sPW, mLicAgent);
                mVault = new ACWT.WebServiceManager(mCred);
                _adm_doc_svc_ext = mVault.DocumentServiceExtensions;
            }

and calling update lifecycle states. the commented out version works fine using the credentials from the user of the client.

                ADMDocSvcExt.UpdateFileLifeCycleStates(new long[] { f.MasterId }, new long[] { relState }, "Prepared for release by - Vault Release Management Utility.");
                
                //DocSvcExt.UpdateFileLifeCycleStates(new long[] { f.MasterId }, new long[] { relState }, "Prepared for release by - Vault Release Management Utility.");
0 Likes
Message 4 of 6

Markus.Koechl
Autodesk
Autodesk

I am sorry, but I don't understand what you try to achieve. The WebServiceManager "mVault" is working...



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 5 of 6

steven_t_gunderson
Contributor
Contributor

at a high level, what i am trying to do is search for all of the files in vault that have the same value in a property and change state on all of those files with an admin user. the basic functionality is below

 

  1. within the vault client, search for a file and select it
  2. on right click, select 'update ERP' which is a custom command
  3. use the logged in vault user to search for all of the files that share the same value for the custom 'ECO' property with the selected file
  4. present the list of files to the user
  5. user selects 'update' to update our ERP system with the various values from the various files
  6. use a specific special vault account to change state of all of the files
  7. present success dialog to the user

the issue happens when i try to use the special vault account to change state.

 

my question is; is it possible to log in to vault with two different users and two different methods at the same time?

 

i am using the logged in, windows authenticated, user to search for files and attempting to also log in with a vault user account to do an action on the files found by the other user.

 

it appears to me that logging in a second time is causing issues. i don't know what may have changed between 2015 and 2020 because of licensing and the way connections are made. i have been able to make the connection to vault with the special vault account but i was not able to do a state change.

 

0 Likes
Message 6 of 6

steven_t_gunderson
Contributor
Contributor
Accepted solution

Better late than never, I have an update to this issue. It turns out that somewhere between 2015 and 2020 there must have been a change somewhere that this API or something related required Administrator permissions within the Vault. Previously I was able to make this state transition with group participation and state change transitions managing the rights. The special user was in a group that was allowed to make that specific state transition but no other special rights were granted. After testing this exact workflow with an admin account it was successful. I simply promoted the user to admin to solve the issue.

 

I couldn't find any kind of documentation or mention of this anywhere but it seems to me that the m_conn.WebServiceManager.DocumentServiceExtensions.UpdateFileLifeCycleStates() method requires the connected user to have admin granted in Vault. It was a bit of a facepalm when I finally figured it out because it should be something I would have tried throughout the troubleshooting process.

 

In any case, thank you Markus and all of the other Autodesk guys for mulling it over and giving it your best shot. I spent a good couple hours at AU2019 asking everyone I could find. I appreciate all of your help.

0 Likes