Page 1 of 1

Polarion and Enterprise Architect

Posted: Fri Mar 05, 2010 9:08 am
by ewiebe
Polarion version:
EA (Sparx Enterprise Architect) version: 7.5.850

Hello, I want to access to polarion workitems through webservice by language C# and VS2008.
I have created web service representation classes with cmd "wsdl ..."

It works!! I can get, query or create workitems !!!
But only if I use it in a stand-alone application !

I have created a C# plug in for EA (version 7.5.850). The Addin itself works fine!
When I access and query polarion items from the EA Addin, I get the same number of polarion items, but they are empty (null).

I use the automatically generated function:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="", ResponseNamespace="", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("queryWorkItemsReturn")]
public WorkItem[] queryWorkItems(string query, string sort, [System.Xml.Serialization.XmlElementAttribute("fields")] string[] fields) {
object[] results = this.Invoke("queryWorkItems", new object[] {
return ((WorkItem[])(results[0]));

I am calling this function in this way:
private void Test()
string qu = "(" + projectId + " AND type:requirement)";
List<string> fields = new List<string>();
WorkItem[] items = trackerService.queryWorkItems(qu, "ID", fields.ToArray());
Debug.WriteLine("WorkItems found: " + items.Length);

It gives me the correct (same) number of work items, but they are all null, although I use the same parameters, in stand-alone-application and in ea-plugin.
Could you follow?

Do you have an idea?
I have tried several possibilities (console app, WinForms app...) but its always the same. When calling from an EA Addin, it does not work.

Re: Polarion and Enterprise Architect

Posted: Fri Mar 05, 2010 10:08 am
by ewiebe
I think, I have the solution:

1. The important thing is that you use special settings:
In you app.config these items must be:
<?xml version="1.0" encoding="utf-8" ?>
<add type="PolarionWS.SessionExtension,PolarionWS"
group="High" />

2. And there must be a special class in your addin (sub)assembly :
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Services.Protocols;
using System.Xml;

namespace PolarionWS
/// <summary>
/// Class for extending SoapExtension class
/// </summary>
public class SessionExtension : System.Web.Services.Protocols.SoapExtension
private const string session_ns = "";
private const string session_name = "sessionID";

private static string sessionId;

/// <summary>
/// Overrides process message function
/// </summary>
/// <param name="message"></param>
public override void ProcessMessage(System.Web.Services.Protocols.SoapMessage message)
if (message.Stage == System.Web.Services.Protocols.SoapMessageStage.AfterDeserialize)
//if after deserialisation
foreach(SoapUnknownHeader header in message.Headers)
if (header.Element.LocalName == session_name && header.Element.NamespaceURI == session_ns)
sessionId = header.Element.InnerText;

else if (message.Stage == System.Web.Services.Protocols.SoapMessageStage.BeforeSerialize && sessionId != null)
//if before deserialisation
SoapUnknownHeader header = new SoapUnknownHeader();
XmlDocument doc = new XmlDocument();
header.Element = doc.CreateElement("session", session_name, session_ns);
header.Element.InnerText = sessionId;

/// <summary>
/// Gets session
/// </summary>
public static string session
return sessionId;

public override object GetInitializer(Type serviceType)
return null;

public override object GetInitializer(System.Web.Services.Protocols.LogicalMethodInfo methodInfo, System.Web.Services.Protocols.SoapExtensionAttribute attribute)
return null;

public override void Initialize(object initializer)

and 3. The application which uses this library must use these configs
I have created a file EA.exe.config and filled with same content as app.config (see above) and added to installation directory of EA (d:\programme\Sparx\EA)
So the application will use these settings when using webservices

Re: Polarion and Enterprise Architect

Posted: Mon Mar 08, 2010 9:17 am
by engeleb
To be honest I wasn't aware that the app.config has to be used by the application that uses the SoapExtension, I thought it is just required for build...
Not sure if it is always possible to use an app.config for a specific application that uses a dll to access our web services, fortunately there are alternatives to the app.config:
1. Add an attribute to each web service method that adds the extension, following attribute should work (not tested): [PolarionWS.SessionExtension(Priorit y=1)]
It should not bee too difficult to come up with a regular expression that adds the attribute to all methods.
2. Register extension programatically like described here: ... Redux.aspx