Hi Everyone,
As I have seen a few questions on the board about talking to CAPA from .NET, so I figured I would share some of the code that I have created to make my own life easier.
Attached you will find the compiled DLL, as well as the source for some of the API functions that I found that I used most commonly to talk to CAPA from my .NET programs and websites.
The .NET API currently contains the following functions:
Submit_CAPA_Job (SOAP)
Abort_CAPA_Job (SOAP)
Check_CAPA_Job (SOAP)
(I have others in-progress, but they aren't fully tested yet)
As I have used these functions in all kinds of projects from Website Launchers, to Command-Line applications, I have tried to make them generic enough to suit multiple purposes.
I (tried to anyhow) document most of the functions nicely in the code, but here is a short sample of how to run a Submit_CAPA_Job.
- Add the DLL as a reference to your project (or add the source as a Class to your project, whatever you would like).
- Make sure to add: using CAPA_API_Calls;
- Each function should show it's requirements, for the Submit_CAPA_Job you need to make sure to supply the following values
- CAPA_Username - User who has rights to run the job in CAPA
- CAPA_Password - Password of the user
- ProcessPath - Full path & name of the process ("/Sandbox/Test-Email")
- Environment - HTTP/HTTPS + FQDN of the CAPA Server + appropriate path
- AdditionalParams - Additional variables that you would like passed to your process. (Optional)
Here is the C# Sample Code:
CAPA_API NewCapaAPI = new CAPA_API();
NewCapaAPI.CAPA_Username = "USERNAME";
NewCapaAPI.CAPA_Password = "PASSWORD";
NewCapaAPI.ProcessPath = "ProcessPath";
NewCapaAPI.Environment = "Environment ";
//If you want to additional custom variables to be passed to your application, you will do it like this
//Pass them all on one line
NewCapaAPI.AdditionalParams = "<itp:param name=\"param1\">Value1</itp:param><itp:param name=\"param2\">Value2</itp:param>";
//Or in multiple small lines (i.e. in a loop), as the string will accept multiple values concatinated together.
NewCapaAPI.AdditionalParams = "<itp:param name=\"param1\">Value1</itp:param>";
NewCapaAPI.AdditionalParams += "<itp:param name=\"param2\">Value2</itp:param>";
String[] Reply = NewCapaAPI.Submit_CAPA_Job();
String SOAP_Reply = "";
if (Reply[0] == "0")
{
SOAP_Reply = Reply[1].ToString();
//Handle successful processing
}
else
{
SOAP_Reply = Reply[1].ToString();
//Handle failed processing
}
The functions will return a String Array:
- [0] value will be either a 0 for success, or a 1 for failure.
- [1] value will contain the SOAP response from the CAPA server, you can parse it for whatever values you are looking for.
I have tried to keep the code itself short and sweet, as that is how I find it is the most flexible for me, and I hope you guys will find it to be as useful as I did.
If you have any issues, please let me know as I am always willing to try and help out (time permitting of course )
Ian Rich
Sr. Automation Analyst, IT Operations Management
CN Rail