Creation of Workitem comments over WebService fails

Description
poldi
Posts: 1
Joined: Tue Aug 03, 2010 6:32 am

Creation of Workitem comments over WebService fails

Postby poldi » Tue Aug 03, 2010 3:31 pm

Hi

I'm writing a small .net C# WebService client that should add new comments to a work item.
Unfortunately without success. Until yet I wasn't able to figure out what I'm doing wrong.
We are using Polarion (ALM) with the build number 3.4.1.20100126-0441.

I started by using the wsdl.exe tool to get the web service proxies. For that I had to use
the following command line:

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>wsdl /sharetypes /n:PolarionWS /o:c:\temp\PolarionWS.cs
http://polarionalm-phonak.sonova.com/po ... rvice?wsdl
http://polarionalm-phonak.sonova.com/po ... rvice?wsdl
http://polarionalm-phonak.sonova.com/po ... rvice?wsdl
http://polarionalm-phonak.sonova.com/po ... rvice?wsdl
http://polarionalm-phonak.sonova.com/po ... rvice?wsdl /pd:mydomain/pp:password /pu:user

and added the generated code to my project. From another post in this forum I downloaded the SessionExtension.cs file
http://forums.polarion.com/viewtopic.php?f=5&t=9035&p=12600&hilit=SessionExtension#p12600 and added that
also to the project.

Following the code I used test the web service (just a prototype):

Code: Select all


                sessionService.logIn(section.User, section.Password);

                sessionService.beginTransaction();

                Project p = Container.Resolve<ProjectWebServiceService>().getProject("PG_PH_PJ");

                string suburi = @"subterra:data-service:objects:/default/PG_PH_PJ${Module}Automated Test";

                Module autoModule = trackerService.getModuleByUri(suburi);

                bool failed = true;
                WorkItem workItem;
                string workItemUri = null;

                try
                {
                    Project project = Container.Resolve<ProjectWebServiceService>().getProject(section.PolarionProjectId);

                    if (project.unresolvable)
                    {
                        System.Diagnostics.Debug.WriteLine("Failed to load project " + section.PolarionProjectId + ".");
                    }
                    else
                    {
                        workItem = new WorkItem();
                        workItem.project = project;
                        workItem.type = new EnumOptionId();
                        workItem.type.id = "automatedtest";
                        workItem.title = "My Titel";
                        workItem.description = new Text();
                        workItem.description.type = "text/html";
                        workItem.description.content = "Ipsum lorem....";
                        workItem.moduleURI = autoModule.uri;
                        workItemUri = trackerService.createWorkItem(workItem);
                    }
                }
                catch(Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
                finally
                {
                    sessionService.endTransaction(failed);
                }

                //Until here every things seams to work fine. The workItemUri returned by createWorkItem looks ok.

                try
                {
                    sessionService.beginTransaction();

                    workItem = trackerService.getWorkItemByUri(workItemUri); //From here it starts getting weird
                   
                    //The workItem.moduleURI, workItem.project and a few more properties are empty

                    Text comment = new Text();
                    comment.content = "<p>Test</p>";
                    comment.type = "text/html";
                    comment.contentLossy = false;
                    trackerService.createComment(workItemUri, comment); //this call throws the exception.
                }
                finally
                {
                    sessionService.endTransaction(failed);
                }



1. After the log in and few additional calls to the webservices, I tell the trackerService to create the work item.
The first impression is that the call is successful, because I get back a new uri for that work item

2. After the call

Code: Select all

 workItem = trackerService.getWorkItemByUri(workItemUri);
my impression changes.
The returned work item seems to be uncompleted. A couple of properties (workItem.moduleURI, workItem.project,...)
are not set to any values.

3. A couple of lines later the call of

Code: Select all

 trackerService.createComment(workItemUri, comment);

fails by throwing the following exception.

System.Web.Services.Protocols.SoapException was unhandled
Message="com.polarion.platform.persistence.UnresolvableObjectException:
uri: subterra:data-service:objects:/default/PG_PH_PJ${WorkItem}PG-PH-PJ-399"
Source="System.Web.Services"
Actor=""
Lang=""
Node=""
Role=""
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at PolarionWS.TrackerWebServiceService.createComment(String workitemURI, Text content) in C:\Users\ama\Projects\SVNRepos\testbed2\TestBed\source\Testbed2Polarion\source\Testbed2WorkItemUpdater\PolarionWS.cs:line 2073
at Sonova.Testbed2WorkItemUpdater.Program.Main(String[] args) in C:\Users\ama\Projects\SVNRepos\testbed2\TestBed\source\Testbed2Polarion\source\Testbed2WorkItemUpdater\Program.cs:line 131
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

I spent more than two days trying to figure out what I'm doing wrong. Any ideas, tips?

Best regards
Poldi

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

Re: Creation of Workitem comments over WebService fails

Postby engeleb » Thu Aug 05, 2010 4:05 pm

Hi,
the problem is that you rollback the transaction you created the work item in.
You should set failed = false as last statement of the code that is runs in the transaction.

Best Regards,
Benjamin


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 8 guests