==== Web Service: LockRemoteXmlFile ==== The LockRemoteXmlFile web service is used to place a lock on an XML file that resides in a remote shared folder. This call will typically precede a call to the GetRemoteXmlFile web service. The LockRemoteXmlFile web service, returns a lock key. The lock key is a required parameter for both the GetRemoteXmlFile and the RemoveLockedRemoteXmlFile web service calls. Request Endpoint {{tablelayout?colwidth="75px,575px"&rowsFixed=1&rowsVisible=10&float=center}} ^ Method ^ URL ^ | POST | https://apex-prd.certna.org/APEX/Service/APEXPublicServer.svc/lockremotexmlfile | Request Body This endpoint accepts request body parameters using an application/json format. Request Headers {{tablelayout?colwidth="150px,450px"&rowsFixed=1&rowsVisible=10&float=center}} ^ Key ^ Value ^ | Content-Type | application/json | JSON Request Parameters {{tablelayout?colwidth="150px,75px,100px,275px"&rowsFixed=1&rowsVisible=10&float=center}} ^ Parm Name ^ Req/Opt ^ Format ^ Description ^ | checksum | Required | [string] | Locally calculated binary checksum value converted to a Base64 string. | JSON Response Parameters {{tablelayout?colwidth="125px,100px,375px"&rowsFixed=1&rowsVisible=10&float=center}} ^ Parm Name ^ Format ^ Description ^ | checksum_key | [string] | The key of the checksum record that was stored in the CeRTNA Portal. | | code | [string] | Exception conditions will result in code/message being returned. | | message | [string] | Longer description of exception condition. | As noted, any condition that results in an unsuccessful call to the StoreChecksum web service will produce a JSON formatted response with a code and message property populated. Successful calls will result in the checksum_key property being returned. The checksum_key is a required parameter of the ValidateChecksum web service. Sample Request **Endpoint:** https://apex-prd.certna.org/APEX/Service/APEXPublicServer.svc/storechecksum **Headers:** Content-Type: application/json **Body:** { "checksum" : "1/l1YnJ1dnWFVbjEcUfp3IkBkPb1XBWhdC34T6nJ3YB859YuAtbhUUEG8Gcwimd1" } Sample Response Status Code: 200 { "checksum_key": "315E7449-1A67-44A8-BCF4-7EB43666D54D" } **OR** Status Code: 500 (When an error occurs.) (example 1) { "Exception": { "Code": "DatabaseError", "Message": "Procedure or function 'spStoreChecksumValue' expects parameter '@CHECKSUM_VALUE', which was not supplied." } } Additional Comments Comments and sample code are provided for reference purposes only and are not intended to show all exception handling conditions and/or completed code blocks. **Comment 1:** The StoreChecksum web service requires a Base64 encoded SHA384 checksum to be provided as one of the parameters. Following is a C# / .NET sample code snippet that shows how to generate a SHA3 checksum and convert the hash to a Base64 string: {{page>[:guides:sample_sha384_hash&noheader&noindent&nofooter&nouser&nodate&noeditbtn&nopermalink]}} **Comment 2:** Following is a C# / .NET sample code snippet that shows how to call the StoreChecksum web service. Your code will supply the values for the various parameters based on the following: {{tablelayout?colwidth="150px,450px"&rowsFixed=1&rowsVisible=10&float=center}} ^ Parameter ^ Source ^ | checksum | The Base64 encoded value of the SHA384 binary checksum that was calculated for the DOCUMENT string. | Public static void StoreChecksumExample() { // In this example I am picking up the checksum value I calculated from a // form field in the sample application that is available on this Wiki. string strChecksumValue = tbChecksumValue.Text; // The following value was obtained from your call to the Login web service. string token = "ab34xyz3..."; strURL = null; client = null; request = null; response = null; strURL = "https://apex-prd.certna.org/APEX/Service/APEXPublicServer.svc/storechecksum"; client = new RestClient(strURL); request = new RestRequest(Method.POST); strParms = "{\n\t\"checksum\" : \""; strParms += strChecksumValue; strParms += "\"\n}"; request.AddHeader("Cache-Control", "no-cache"); request.AddHeader("Content-Type", "application/json"); request.AddHeader("access_token", token); request.AddParameter("StoreChecksum", strParms, ParameterType.RequestBody); response = client.Execute(request); if (response.IsSuccessful) { var jsonResult2 = JsonConvert.DeserializeObject(response.Content); string strChecksumKey = jsonResult2.checksum_key; // (Agents) Update the RequestChecksumValue property of the PRIA_DOCUMENT node with the value of strChecksumKey // or // (Counties) Update the ResponseChecksumValue property of the PRIA_DOCUMENT node with the value of strChecksumKey } else { var jsonResult2 = JsonConvert.DeserializeObject(response.Content); string str_ErrorCode = jsonResult2.ToString(); // Do something with the error result } } **Comment 3:** Please note that before calling the CeRTNA web services you must establish the SecurityProtocol in your ServicePointManager. An example is shown below. The currently recommended protocol is Tls12. public MainWindow() { InitializeComponent(); System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; } **Comment 4:** CeRTNA has posted a simple [[:guides:sample_web_service_project|Visual Studio 2015 WPF/C# project]] on the CeRTNA Wiki that demonstrates how to look up values in an XML file and how to use the Login, StoreChecksum, and ValidateChecksum web services. The project can be downloaded from the Wiki. As stated earlier, the purpose of the code samples is not to demonstrate well structured code, but rather to provide a very simple, functional sample, that you can use for reference in adding CeRTNA web service calls to your existing application. The code sample is provided as is, however, your production code would be expected to contain more extensive error handling, etc. **Comment 5:** A nice utility for experimenting with web service calls is POSTMAN. You can download a free version of POSTMAN from the following URL: https://www.getpostman.com/apps