Inflectra Customer Forums: FYI - quick steps to read & write data through SOAP interface with C# (Thread) As a community service, here are some quick steps to start using the SOAP interface so that you can programmatically read and write data in your SpiraTeam instance. These steps are for .NET C#. These steps supplant the Inflectra knowledge base article " How to access Spira v3.x SOAP web services using C# ". Use at your own risk. 1. Download and install the free Visual Studio 2013 Express for Windows Desktop. 2. Through it, start a new project. Use the template for a Visual C# Console Application project. 3. Through the menu 'Project', add a service reference. For the address, provide the correct URL for your instance's SOAP interface. It may look something like the following, which is for our hosted instance: https://edmap.spiraservice.net/Services/v4_0/ImportExport.svc. Change the namespace from ServiceReference1 to "SpiraImportExport40". 4. Replace all the code in your program.cs file with the code after the line below. 5. Then, in the program.cs file, do the following: 5a. On line, 19, r eplace the EndPoint web address with the appropriate URL for your instance's SOAP interface. (The same URL you used in step 3.) 5b. On lines 27 and 32, adjust the key/id fields. Use a valid project id and a valid release id. 5c. On line 28, provide your username and password. 6. If the URL you are using starts with "https" instead of "http", then do the following. 6a. Through the Edit menu, do a Replace in Files. Replace "ttpBind" with "ttpsBind" in your entire solution. Replace All. (Should be 36 replacements.) 6b. In the program.cs file on line 24, replace "BasicHttpSecurityMode.None" with "BasicHttpsSecurityMode.Transport". 7. Build the solution and start it. Enjoy. program.cs code: ------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { //The following code will connect to Spira, authenticate, connect to a project and then get a list of incidents fixed in a specific release: //Instantiate the web-service proxy class and set the URL from the .config file SpiraImportExport40.ImportExportClient spiraImportExport = new SpiraImportExport40.ImportExportClient(); spiraImportExport.Endpoint.Address = new EndpointAddress("http://servername/SpiraTest/Services/v3_0/ImportExport.svc"); //Configure the HTTP Binding to handle session cookies BasicHttpBinding httpBinding = (BasicHttpBinding)spiraImportExport.Endpoint.Binding; httpBinding.AllowCookies = true; httpBinding.Security.Mode = BasicHttpSecurityMode.None; //Next lets authenticate and connect to the project int projectId = 1; spiraImportExport.Connection_Authenticate("username", "password"); spiraImportExport.Connection_ConnectToProject(projectId); //Now lets get a list of incidents fixed in Release RL00005 int releaseId = 5; List remoteFilters = new List (); SpiraImportExport40.RemoteFilter remoteFilter = new SpiraImportExport40.RemoteFilter(); remoteFilter.PropertyName = "ResolvedReleaseId"; remoteFilter.IntValue = releaseId; remoteFilters.Add(remoteFilter); SpiraImportExport40.RemoteSort remoteSort = new SpiraImportExport40.RemoteSort(); remoteSort.PropertyName = "Name"; remoteSort.SortAscending = true; SpiraImportExport40.RemoteIncident[] remoteIncidents = spiraImportExport.Incident_Retrieve(remoteFilters.ToArray(), remoteSort, 1, 999999); //Loop through and display ID, name and description foreach (SpiraImportExport40.RemoteIncident remoteIncident in remoteIncidents) { Console.WriteLine(remoteIncident.IncidentId + " | " + remoteIncident.Name); } Console.WriteLine(""); Console.Write("Press Enter to Exit..."); Console.ReadLine(); spiraImportExport.Connection_Disconnect(); } } } en-US(C) Copyright 2006-2024 Inflectra Corporation.support@inflectra.com/Computers/Software/Project_Management//Computers/Software/Quality_Assurance/KronoDesksupport@inflectra.comhttp://www.inflectra.com/kronodesk/forums/threads120/Support/Forum/spirateam/issues-questions/1130.aspxthreadId=1130Jon Freed (jfreed@edmap.com)csharp SOAP quick-startFYI - quick steps to read & write data through SOAP interface with C# As a community service, here are some quick steps to start using the SOAP interface so that you can programmatically read and write data in your SpiraTeam instance. These steps are for .NET C#. These steps supplant the Inflectra knowledge base article " How to access Spira v3.x SOAP web services using C# ". Use at your own risk. 1. Download and install the free Visual Studio 2013 Express for Windows Desktop. 2. Through it, start a new project. Use the template for a Visual C# Console Application project. 3. Through the menu 'Project', add a service reference. For the address, provide the correct URL for your instance's SOAP interface. It may look something like the following, which is for our hosted instance: https://edmap.spiraservice.net/Services/v4_0/ImportExport.svc. Change the namespace from ServiceReference1 to "SpiraImportExport40". 4. Replace all the code in your program.cs file with the code after the line below. 5. Then, in the program.cs file, do the following: 5a. On line, 19, r eplace the EndPoint web address with the appropriate URL for your instance's SOAP interface. (The same URL you used in step 3.) 5b. On lines 27 and 32, adjust the key/id fields. Use a valid project id and a valid release id. 5c. On line 28, provide your username and password. 6. If the URL you are using starts with "https" instead of "http", then do the following. 6a. Through the Edit menu, do a Replace in Files. Replace "ttpBind" with "ttpsBind" in your entire solution. Replace All. (Should be 36 replacements.) 6b. In the program.cs file on line 24, replace "BasicHttpSecurityMode.None" with "BasicHttpsSecurityMode.Transport". 7. Build the solution and start it. Enjoy. program.cs code: ------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication3 { class Program { static void Main(string[] args) { //The following code will connect to Spira, authenticate, connect to a project and then get a list of incidents fixed in a specific release: //Instantiate the web-service proxy class and set the URL from the .config file SpiraImportExport40.ImportExportClient spiraImportExport = new SpiraImportExport40.ImportExportClient(); spiraImportExport.Endpoint.Address = new EndpointAddress("http://servername/SpiraTest/Services/v3_0/ImportExport.svc"); //Configure the HTTP Binding to handle session cookies BasicHttpBinding httpBinding = (BasicHttpBinding)spiraImportExport.Endpoint.Binding; httpBinding.AllowCookies = true; httpBinding.Security.Mode = BasicHttpSecurityMode.None; //Next lets authenticate and connect to the project int projectId = 1; spiraImportExport.Connection_Authenticate("username", "password"); spiraImportExport.Connection_ConnectToProject(projectId); //Now lets get a list of incidents fixed in Release RL00005 int releaseId = 5; List remoteFilters = new List (); SpiraImportExport40.RemoteFilter remoteFilter = new SpiraImportExport40.RemoteFilter(); remoteFilter.PropertyName = "ResolvedReleaseId"; remoteFilter.IntValue = releaseId; remoteFilters.Add(remoteFilter); SpiraImportExport40.RemoteSort remoteSort = new SpiraImportExport40.RemoteSort(); remoteSort.PropertyName = "Name"; remoteSort.SortAscending = true; SpiraImportExport40.RemoteIncident[] remoteIncidents = spiraImportExport.Incident_Retrieve(remoteFilters.ToArray(), remoteSort, 1, 999999); //Loop through and display ID, name and description foreach (SpiraImportExport40.RemoteIncident remoteIncident in remoteIncidents) { Console.WriteLine(remoteIncident.IncidentId + " | " + remoteIncident.Name); } Console.WriteLine(""); Console.Write("Press Enter to Exit..."); Console.ReadLine(); spiraImportExport.Connection_Disconnect(); } } } Tue, 13 Jan 2015 20:06:35 -05002018-11-08T15:08:46-05:00/Support/Forum/spirateam/issues-questions/1130.aspxmessageId=2013Jon Freed (jfreed@edmap.com) Good catch on the namespace, . New step , 5d : Unless your project name is "Console Good catch on the namespace, . New step , 5d : Unless your project name is "ConsoleApplication3 (and it probably isn't), then on line 8, change "ConsoleApplication3" so that it matches the name of your project. The error regarding BasicHtt pB inding versus BasicHtt p s B inding was somewhat expected depending on the URL you are using for your instance's SOAP interface. See my step 6. However, I'm not sure if that explains what you encountered. You stated that you're using Visual Studio 201 0 , but the steps are for VS 201 3 . You might try 2013 to see if that resolves any remaining problems. Wed, 14 Jan 2015 14:45:28 -05002015-02-09T15:16:31-05:00/Support/Forum/spirateam/issues-questions/1130.aspx#reply2013messageId=3436Lance Snead (lance.snead@gmail.com) Thanks for taking the time to write this up. It was very helpful in getting started. Were going to Thanks for taking the time to write this up. It was very helpful in getting started. Were going to integrate this into our automation build process to create releases in Spira automatically. Thu, 08 Nov 2018 15:08:46 -05002018-11-08T15:08:46-05:00/Support/Forum/spirateam/issues-questions/1130.aspx#reply3436