views:

91

answers:

1

Hi,

I'm trying to attach some files to a Jira using the Soap API. I have python 2.6 and SOAPpy isn't working any more, so, I'm using suds. Everything is fine except for the attachements ... I don't know how to rewrite this piece of code : http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client?focusedCommentId=180943#comment-180943

Any clue ? I don't know how to deal with complex type like this one :

<complexType name="ArrayOf_xsd_base64Binary">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:byte[][]"/>
</restriction>
</complexContent>
</complexType>

thanks a lot

n.

A: 

dunno if this helps but when I was using python the handle wsdls I found a distinct lack of support in most packages for complex types. In the end I decided on zsi with its wsdl2py --complexType wsdl_url. This worked perfectly. I had many complex types in my wsdl with arrays of arrays of arrays defined in the wsdl. wsdl2py generates 3 libs that you use when accessing the wsdl. Here is an example of a call to a method createSubscribers which takes in arrays of values.

import inspect, sys
from PolicyManagementService_client import *

class apiCheckSetup:
    def __init__(self, host="10.10.10.23", port="8080", log=None):
        """Setup to run wsdl operations"""
        self.loc=PolicyManagementServiceLocator(host, port)
        if log:
            logfile=log
        else:
            logfile=sys.stdout
        kw = { 'tracefile'    :    logfile}
        self.port=self.loc.getPolicyManagementPort(**kw)

    def createSubscribers(self, subList):
        req=createSubscribers()
        subscriberList=ns0.subscriberDetailsList_Def("subscriberList")
        subscriber=ns0.subscriberDetails_Def("subscriber")
        subUsers=subscriberList.pyclass()
        for element in subList:
            sub=subscriber.pyclass()
            sub.set_attribute_msisdn(element['msisdn'])
            sub.set_attribute_policyID(element['policyID'])
            sub.set_attribute_firstName(element['firstName'])
            sub.set_attribute_lastName(element['lastName'])
            subUsers._subscriber.append(sub)
        req._subscribers=subUsers
        self.port.createSubscribers(req)

This can be called like so:

subList=[{'msisdn' : '+445555555', 'policyID' :  pid, 'firstName' : 'M1', 'lastName' : 'D1'}, {'msisdn' : '+445555556', 'policyID' :  pid, 'firstName' : 'M2', 'lastName' : 'D2'}] 
    self.api=pmcApiMethods.apiCheckSetup(host=testConfig.pmcApiServer, port=testConfig.pmcApiPort)
    self.api.createSubscribers(subList)

Dunno if this is any help

amadain