Skip Navigation LinksForums > SpiraTeam Forums > SpiraTeam Issues & Questi... > FYI - quick steps to read...

FYI - quick steps to read & write data through SOAP interface with C# RSS Feed

Tuesday, January 13, 2015
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:  
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, replace 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");

            //Now lets get a list of incidents fixed in Release RL00005
            int releaseId = 5;
            List<SpiraImportExport40.RemoteFilter> remoteFilters = new List<SpiraImportExport40.RemoteFilter>();
            SpiraImportExport40.RemoteFilter remoteFilter = new SpiraImportExport40.RemoteFilter();
            remoteFilter.PropertyName = "ResolvedReleaseId";
            remoteFilter.IntValue = releaseId;
            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.Write("Press Enter to Exit...");

1 Replies
Jon FreedJon Freed
re: Jon Freed on Tuesday, January 13, 2015
Monday, February 9, 2015
Good catch on the namespace, <Message Deleted>.  

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 BasicHttpBinding versus BasicHttpsBinding 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 2010, but the steps are for VS 2013.  You might try 2013 to see if that resolves any remaining problems.
  • Started: 1/13/2015
  • Last Reply: 2/9/2015
  • Replies: 1
  • Views: 1077
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.