Polarion and Enterprise Architect

Description
ewiebe
Posts: 11
Joined: Fri Feb 26, 2010 3:05 pm

Polarion and Enterprise Architect

Postby ewiebe » Fri Mar 05, 2010 9:08 am

Polarion version: 3.3.2.20090901-1653
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 !

Problem:
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="http://ws.polarion.com/TrackerWebService-impl", ResponseNamespace="http://ws.polarion.com/TrackerWebService-impl", 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[] {
query,
sort,
fields});
return ((WorkItem[])(results[0]));
}


I am calling this function in this way:
private void Test()
{
string qu = "(project.id:" + projectId + " AND type:requirement)";
List<string> fields = new List<string>();
fields.Add("id");
fields.Add("title");
fields.Add("description");
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.

ewiebe
Posts: 11
Joined: Fri Feb 26, 2010 3:05 pm

Re: Polarion and Enterprise Architect

Postby ewiebe » Fri Mar 05, 2010 10:08 am

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" ?>
<configuration>
<system.web>
<webServices>
<soapExtensionTypes>
<add type="PolarionWS.SessionExtension,PolarionWS"
priority="1"
group="High" />
</soapExtensionTypes>
</webServices>
</system.web>
</configuration>



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 = "http://ws.polarion.com/session";
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;
message.Headers.Add(header);
}
}


/// <summary>
/// Gets session
/// </summary>
public static string session
{
get
{
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

engeleb
Posts: 199
Joined: Wed Aug 09, 2006 10:55 am

Re: Polarion and Enterprise Architect

Postby engeleb » Mon Mar 08, 2010 9:17 am

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: http://blog.gatosoft.com/2005/07/31/Pro ... Redux.aspx


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Google [Bot], patriciakk11, RidgeJelo and 14 guests