Get work item from web service using Python / suds fails

Description
baxter
Posts: 3
Joined: Wed Aug 22, 2018 7:19 am

Get work item from web service using Python / suds fails

Postby baxter » Wed Aug 22, 2018 7:43 am

Hello everybody,
I am currently struggling to receive work item objects using python and suds to communicate with the web services.

First I query Polarion for the work item that I need, this works:

Code: Select all

    def query_workitems(self, query, fields):
        return self.polarion.tracker.service.queryWorkItems('project.id:%s AND %s' % (self.project_id, query),'id',fields)

    def query_sw_data(self, filepath):
        split_path = split_datapath(filepath)
        prefix = split_path[0]
        title = split_path[1]
        fields = ['id']
        return self.query_workitems('type:LLI_data AND title:{0} AND cf_path_prefix:{1}'.format(title, prefix), fields)


Then I try to get the work item object by the ID that the query returned:

Code: Select all

    def getWI(self, workitemId):
        return self.polarion.tracker.service.getWorkItemById(self.polarion_prj, workitemId)


But now I receive the error suds.TypeNotFound: Type not found: '_uri'.

This is how I connect to the web services:

Code: Select all

        url_SessionWebService  = '{0}/ws/services/SessionWebService?wsdl'.format(self.url)
        url_TrackerWebService  = '{0}/ws/services/TrackerWebService?wsdl'.format(self.url)
        url_ProjectWebService  = '{0}/ws/services/ProjectWebService?wsdl'.format(self.url)

        imp_tracker = Import('http://schemas.xmlsoap.org/soap/encoding/')
        imp_tracker.filter.add('http://ws.polarion.com/TrackerWebService-types')
        imp_tracker.filter.add('http://ws.polarion.com/TrackerWebService')
        imp_tracker.filter.add('http://ws.polarion.com/ProjectWebService-types')
        imp_tracker.filter.add('http://ws.polarion.com/PlanningWebService-types')
        imp_tracker.filter.add('http://ws.polarion.com/types')
        doctor_tracker = ImportDoctor(imp_tracker)

        imp_project = Import('http://schemas.xmlsoap.org/soap/encoding/')
        imp_project.filter.add('http://ws.polarion.com/ProjectWebService-types')
        imp_project.filter.add('http://ws.polarion.com/types')
        doctor_project = ImportDoctor(imp_project)

        self.session = Client(url_SessionWebService)
        self.__tracker = Client(url_TrackerWebService, doctor=doctor_tracker)
        self.__project_ws = Client(url_ProjectWebService, doctor=doctor_project)
        self.session.service.logIn(self.username, self.password)

        # Retrieve session ID and add it to soapheader.
        m=header_regex.search(self.session.last_received().str())
        sessionId=m.group(1)
        session_ns=('ns1', 'http://ws.polarion.com/session')
        ns1 = Element('sessionID', ns=session_ns).setText(sessionId)
        self.__tracker.set_options(soapheaders=ns1)


Has anyone else experienced (and hopefully solved) this problem?

baxter
Posts: 3
Joined: Wed Aug 22, 2018 7:19 am

Re: Get work item from web service using Python / suds fails

Postby baxter » Wed Aug 22, 2018 12:22 pm

After a lot of failed tries with the function getWorkItemById I tried the function getWorkItemByUri and it worked right away. Quite unexpected, as I thought the same suds error would appear.

So I cannot explain why getWorkItemById did not work, if you can just switch to getWorkItemByUri!

Code: Select all

    def getWI(self, workitemUri):
        return self.polarion.tracker.service.getWorkItemByUri(workitemUri)


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: Google [Bot] and 5 guests