guides:ws_payloads_lock_unlock_finalize
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| guides:ws_payloads_lock_unlock_finalize [2020/08/24 00:45] – brett.zamora | guides:ws_payloads_lock_unlock_finalize [2020/08/24 23:30] (current) – brett.zamora | ||
|---|---|---|---|
| Line 155: | Line 155: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | |||
| + | **Comment 1:** | ||
| + | |||
| + | Following is a C# / .NET sample code snippet that shows how to call the web services associated with locking, unlocking, and finalizing a payload. | ||
| + | |||
| + | The lock, unlock, and finalize web services are web services that are used as part of the send payload and retrieve payload process flow. | ||
| + | |||
| + | Payloads that are ' | ||
| + | |||
| + | Payloads that are ' | ||
| + | |||
| + | The sample code snippets that appear below show the usage for all 3 web services. (Lock, Unlock, Finalize) | ||
| + | |||
| + | These snippet of code was derived from the [[guides: | ||
| + | |||
| + | |||
| + | **Snippet 1: Lock/ | ||
| + | |||
| + | |||
| + | <code C#> | ||
| + | private bool LockUnlockRemoteFile(string strRepositoryType, | ||
| + | { | ||
| + | bool rc = false; | ||
| + | |||
| + | if (strAction == " | ||
| + | { | ||
| + | tbMessageLine.Text = " | ||
| + | } | ||
| + | else if (strAction == " | ||
| + | { | ||
| + | tbMessageLine.Text = " | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | tbMessageLine.Text = ""; | ||
| + | } | ||
| + | |||
| + | RestClient client = null; | ||
| + | RestRequest request = null; | ||
| + | IRestResponse response = null; | ||
| + | |||
| + | string strURL = " | ||
| + | |||
| + | // Password has to be hashed. | ||
| + | // New convention uses a Salt value from the user record | ||
| + | // See the Login web service for more detail. | ||
| + | |||
| + | string strSalt = GetSalt(tbUserName.Text); | ||
| + | string strPassword = tbPassword.Password.ToString(); | ||
| + | |||
| + | string strHashedPassword = HashPassword(strPassword, | ||
| + | |||
| + | string strParms = " | ||
| + | strParms += tbUserName.Text; | ||
| + | strParms += " | ||
| + | strParms += strHashedPassword; | ||
| + | strParms += " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.POST); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | |||
| + | request.AddParameter(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | var jsonResult1 = JsonConvert.DeserializeObject< | ||
| + | string token = jsonResult1.access_token; | ||
| + | |||
| + | strURL = null; | ||
| + | client = null; | ||
| + | request = null; | ||
| + | response = null; | ||
| + | |||
| + | strURL = " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.PATCH); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | if (strAction == " | ||
| + | { | ||
| + | tbMessageLine.Text = " | ||
| + | } | ||
| + | else if (strAction == " | ||
| + | { | ||
| + | tbMessageLine.Text = " | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | tbMessageLine.Text = ""; | ||
| + | } | ||
| + | rc = true; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | string strMessage = jsonResult2.Exception.Message; | ||
| + | tbMessageLine.Clear(); | ||
| + | tbMessageLine.Text = strMessage; | ||
| + | } | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | tbMessageLine.Text = jsonResult2.ToString(); | ||
| + | } | ||
| + | return (rc); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | **Snippet 2: Finalize** | ||
| + | |||
| + | The following is just a fragment of code that was copied over from the [[guides: | ||
| + | |||
| + | <code C#> | ||
| + | var jsonResult2 = JsonConvert.DeserializeObject< | ||
| + | string strRemoteFileName = jsonResult2.result; | ||
| + | |||
| + | // You must finalize the remote file to change the extension from .tmp to .xml | ||
| + | | ||
| + | string strAction = " | ||
| + | |||
| + | strURL = null; | ||
| + | client = null; | ||
| + | request = null; | ||
| + | response = null; | ||
| + | |||
| + | strURL = " | ||
| + | |||
| + | client = new RestClient(strURL); | ||
| + | request = new RestRequest(Method.PATCH); | ||
| + | |||
| + | request.AddHeader(" | ||
| + | request.AddHeader(" | ||
| + | response = client.Execute(request); | ||
| + | |||
| + | if (response.IsSuccessful) | ||
| + | { | ||
| + | tbMessageLine.Text = "XML file " + strFileName+" | ||
| + | rc = true; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | var jsonResult3 = JsonConvert.DeserializeObject< | ||
| + | string strMessage = jsonResult3.Exception.Message; | ||
| + | tbMessageLine.Text = strMessage; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | **Comment 2:** | ||
| + | |||
| + | A nice utility for experimenting with web service calls is POSTMAN. You can download a free version of POSTMAN from the following URL: https:// | ||
| + | |||
| + | |||
| + | |||
guides/ws_payloads_lock_unlock_finalize.1598229920.txt.gz · Last modified: by brett.zamora
