• Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Medium Medium
    • None
    • None
    • SOAP

      I'm attempting to get Crowd to work with the Python ZSI code-generation facilities. However when running wsdl2py on the Crowd WSDL I get the following error:

      ZSI.generate.Wsdl2PythonError: No built-in typecode for type definition("http://exception.integration.crowd.atlassian.com","InvalidAuthorizationTokenException"): <schema targetNamespace="urn:SecurityServer"><element name="InvalidAuthorizationTokenException">

      This appears to be because the exception namespaces are not imported. Adding the lines:

      <xsd:import namespace="http://exception.integration.crowd.atlassian.com"/>
      <xsd:import namespace="http://rmi.java"/>

      to the urn:SecurityServer schema appears to fix this.

            [CWD-159] WSDL doesn't import exception namespaces

            intersol_old added a comment -

            I upgraded to 2.7.2 and now it works, you can close this one as fixed in 2.7.2 and duplicate of CWD-3838

            intersol_old added a comment - I upgraded to 2.7.2 and now it works, you can close this one as fixed in 2.7.2 and duplicate of CWD-3838

            Hi intersol,

            I suspect CWD-1738 has a different cause. Please take a look to my comment to that issue.

            Diego Berrueta added a comment - Hi intersol , I suspect CWD-1738 has a different cause. Please take a look to my comment to that issue.

            intersol_old added a comment -

            I am wondering if is related to https://jira.atlassian.com/browse/CWD-1738 – or if SOAP just became totally broken because atlassian changed DNS or put the WDSL webservers down.

            intersol_old added a comment - I am wondering if is related to https://jira.atlassian.com/browse/CWD-1738 – or if SOAP just became totally broken because atlassian changed DNS or put the WDSL webservers down.

            Hi all,

            I'm trying Shawn's code with

            p = client.service.findPrincipalWithAttributesByName(token,user)

            in order to return more data. However I'm getting:

            Traceback (most recent call last):
            File "./crowdupdate.py", line 144, in <module>
            principal = dict([ (y["name"],y["values"][0][0]) for y in p.attributes[0] ])
            IndexError: list index out of range

            Having compared the two out puts i don't see a logical reason for this, can anyone shed any light on this please?

            Ric

            Richard Harvey added a comment - Hi all, I'm trying Shawn's code with p = client.service.findPrincipalWithAttributesByName(token,user) in order to return more data. However I'm getting: Traceback (most recent call last): File "./crowdupdate.py", line 144, in <module> principal = dict([ (y ["name"] ,y ["values"] [0] [0] ) for y in p.attributes [0] ]) IndexError: list index out of range Having compared the two out puts i don't see a logical reason for this, can anyone shed any light on this please? Ric

            Shawn K. O'Shea that works perfectly. I'm pretty new to crowd and python but that helped a lot!

            Richard Harvey added a comment - Shawn K. O'Shea that works perfectly. I'm pretty new to crowd and python but that helped a lot!

            Thanks Ronald for your suds code. It was really helpful. I was playing with it and found in the suds documentation that missing namespaces is apparently so common in WSDLs that suds provides a module called the ImportDoctor for fixing broken namespaces (so no need to manually patch the WSDL). Attached is my code example code (based on yours) that uses the import doctor to patch the wsdl.

            suds-crowd.py
            from suds.client import Client
            import suds.xsd.doctor as dr
            
            # See http://jira.atlassian.com/browse/CWD-159 for the necessary edits to the WSDL
            wsdlurl="http://127.0.0.1:8085/services/SecurityServer?wsdl"
            
            # Credentials
            appname = "soapuser"
            apppass = "soappassword"
            
            # The following dictionary has the targetNamespace as the key and a list
            # of namespaces that need to be imported as the value for that key
            patches = { "urn:SecurityServer": ["http://authentication.integration.crowd.atlassian.com",
                "http://soap.integration.crowd.atlassian.com","http://exception.integration.crowd.atlassian.com",
                "http://rmi.java"] ,
                "http://soap.integration.crowd.atlassian.com": ["urn:SecurityServer"] }
            
            # Create an ImportDoctor to use
            doctor = dr.ImportDoctor()
            
            # Patch all the imports into the proper targetNamespaces
            for targetNamespace in patches:
                for nsimport in patches[targetNamespace]:
                    imp = dr.Import(nsimport)
                    imp.filter.add(targetNamespace)
                    doctor.add(imp)
            
            # Create the SOAP client, doctoring it to fix imports
            client = Client(wsdlurl,doctor=doctor)
            # Authenticate
            auth_context = client.factory.create('ns1:ApplicationAuthenticationContext')
            auth_context.name = appname
            auth_context.credential.credential = apppass
            token = client.service.authenticateApplication(auth_context)
            
            # print all users in the directories associated with this app
            userlist = client.service.findAllPrincipalNames(token)
            for user in userlist[0]:
                print user
                p = client.service.findPrincipalByName(token,user)
                principal = dict([ (y["name"],y["values"][0][0]) for y in p.attributes[0] ])
                principal["active"]=p.active
                print principal
            

            Shawn K. O'Shea added a comment - Thanks Ronald for your suds code. It was really helpful. I was playing with it and found in the suds documentation that missing namespaces is apparently so common in WSDLs that suds provides a module called the ImportDoctor for fixing broken namespaces (so no need to manually patch the WSDL). Attached is my code example code (based on yours) that uses the import doctor to patch the wsdl. suds-crowd.py from suds.client import Client import suds.xsd.doctor as dr # See http: //jira.atlassian.com/browse/CWD-159 for the necessary edits to the WSDL wsdlurl= "http: //127.0.0.1:8085/services/SecurityServer?wsdl" # Credentials appname = "soapuser" apppass = "soappassword" # The following dictionary has the targetNamespace as the key and a list # of namespaces that need to be imported as the value for that key patches = { "urn:SecurityServer" : [ "http: //authentication.integration.crowd.atlassian.com" , "http: //soap.integration.crowd.atlassian.com" , "http://exception.integration.crowd.atlassian.com" , "http: //rmi.java" ] , "http: //soap.integration.crowd.atlassian.com" : [ "urn:SecurityServer" ] } # Create an ImportDoctor to use doctor = dr.ImportDoctor() # Patch all the imports into the proper targetNamespaces for targetNamespace in patches: for nsimport in patches[targetNamespace]: imp = dr.Import(nsimport) imp.filter.add(targetNamespace) doctor.add(imp) # Create the SOAP client, doctoring it to fix imports client = Client(wsdlurl,doctor=doctor) # Authenticate auth_context = client.factory.create( 'ns1:ApplicationAuthenticationContext' ) auth_context.name = appname auth_context.credential.credential = apppass token = client.service.authenticateApplication(auth_context) # print all users in the directories associated with this app userlist = client.service.findAllPrincipalNames(token) for user in userlist[0]: print user p = client.service.findPrincipalByName(token,user) principal = dict([ (y[ "name" ],y[ "values" ][0][0]) for y in p.attributes[0] ]) principal[ "active" ]=p.active print principal

            Someone requested me for a sample python script that uses Suds to access Crowd. I'm posting it here in case other people find it useful.
            More information on Crowd's SOAP API (and java code samples) can be found here:
            http://confluence.atlassian.com/display/CROWD/SOAP+API

            #!/usr/bin/python
            
            import sys
            import os
            import logging
            import suds.client
            
            # Suds is a lightweight SOAP python client: https://fedorahosted.org/suds/
            # Download .tgz, untar, then install: sudo python setup.py install
            
            # the default crowd .wsdl (http://localhost:8095/crowd/services/SecurityServer?wsdl) 
            # has missing import statements, causing suds to fail, so we use a modified local copy
            # see http://jira.atlassian.com/browse/CWD-159
            
            # place modified wsdl where the script can access it
            #url = 'http://localhost/crowd-fixed.wsdl'
            url='file:///tmp/crowd-fixed.wsdl'
            
            # uncomment this to enable suds debugging messages
            #logging.getLogger('suds.client').setLevel(logging.DEBUG)
            
            client = suds.client.Client(url)
            auth_context = client.factory.create('ns1:ApplicationAuthenticationContext')
            # crowd application name and password
            auth_context.name = 'crowd-soap'
            auth_context.credential.credential = 'password'
            token = client.service.authenticateApplication(auth_context)
            
            # print a user's groups
            user = 'test.user'
            groups = client.service.findGroupMemberships(token, user)
            print user + ' groups:'
            if len(groups) > 0:
                for g in sorted(groups.string):
                    print "  " + g
            else:
                print "  <none>"
            
            # print a group's members
            group = 'jira-users'
            soap_group = client.service.findGroupByName(token, group)
            print
            print group + ' members:'
            if soap_group and soap_group.members:
                for u in sorted(soap_group.members.string):
                    print "  " + u
            else:
                print "  <none>"
            

            Ronald Taneza added a comment - Someone requested me for a sample python script that uses Suds to access Crowd. I'm posting it here in case other people find it useful. More information on Crowd's SOAP API (and java code samples) can be found here: http://confluence.atlassian.com/display/CROWD/SOAP+API #!/usr/bin/python import sys import os import logging import suds.client # Suds is a lightweight SOAP python client: https: //fedorahosted.org/suds/ # Download .tgz, untar, then install: sudo python setup.py install # the default crowd .wsdl (http: //localhost:8095/crowd/services/SecurityServer?wsdl) # has missing import statements, causing suds to fail, so we use a modified local copy # see http: //jira.atlassian.com/browse/CWD-159 # place modified wsdl where the script can access it #url = 'http: //localhost/crowd-fixed.wsdl' url= 'file: ///tmp/crowd-fixed.wsdl' # uncomment this to enable suds debugging messages #logging.getLogger( 'suds.client' ).setLevel(logging.DEBUG) client = suds.client.Client(url) auth_context = client.factory.create( 'ns1:ApplicationAuthenticationContext' ) # crowd application name and password auth_context.name = 'crowd-soap' auth_context.credential.credential = 'password' token = client.service.authenticateApplication(auth_context) # print a user's groups user = 'test.user' groups = client.service.findGroupMemberships(token, user) print user + ' groups:' if len(groups) > 0: for g in sorted(groups.string): print " " + g else : print " <none>" # print a group's members group = 'jira-users' soap_group = client.service.findGroupByName(token, group) print print group + ' members:' if soap_group and soap_group.members: for u in sorted(soap_group.members.string): print " " + u else : print " <none>"

            Thanks to the comments here, I managed to have a python script work with Crowd's soap api. I use "suds", a python soap client library that's quite easy to use (no need to run a wsdl2py).

            However, another import is needed to fix a "Type not found: '(ArrayOfString, urn:SecurityServer, )'" error when using the "findAllPrincipalNames" and "findGroupMemberships" api's.
            The fix is to add the following line under the "http://soap.integration.crowd.atlassian.com" schema:
            <xsd:import namespace="urn:SecurityServer"/>

            Here is the full diff of the fixed wsdl file:

            $ diff -u crowd.wsdl.orig crowd-fixed.wsdl
            --- crowd.wsdl.orig     2009-05-06 15:11:42.000000000 +0200
            +++ crowd-fixed.wsdl    2009-05-06 15:12:08.000000000 +0200
            @@ -42,6 +42,10 @@
             </xsd:complexType>
             </xsd:schema>
             <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:SecurityServer">
            +<xsd:import namespace="http://authentication.integration.crowd.atlassian.com"/>
            +<xsd:import namespace="http://soap.integration.crowd.atlassian.com"/>
            +<xsd:import namespace="http://exception.integration.crowd.atlassian.com"/>
            +<xsd:import namespace="http://rmi.java"/>
             <xsd:element name="findAllGroupRelationships">
             <xsd:complexType>
             <xsd:sequence>
            @@ -642,6 +646,7 @@
             </xsd:element>
             </xsd:schema>
             <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://soap.integration.crowd.atlassian.com">
            +<xsd:import namespace="urn:SecurityServer"/>
             <xsd:complexType name="ArrayOfSOAPNestableGroup">
             <xsd:sequence>
             <xsd:element maxOccurs="unbounded" minOccurs="0" name="SOAPNestableGroup" nillable="true" type="ns2:SOAPNestableGroup"/>
            

            Ronald Taneza added a comment - Thanks to the comments here, I managed to have a python script work with Crowd's soap api. I use "suds", a python soap client library that's quite easy to use (no need to run a wsdl2py). However, another import is needed to fix a "Type not found: '(ArrayOfString, urn:SecurityServer, )'" error when using the "findAllPrincipalNames" and "findGroupMemberships" api's. The fix is to add the following line under the "http://soap.integration.crowd.atlassian.com" schema: <xsd:import namespace="urn:SecurityServer"/> Here is the full diff of the fixed wsdl file: $ diff -u crowd.wsdl.orig crowd-fixed.wsdl --- crowd.wsdl.orig 2009-05-06 15:11:42.000000000 +0200 +++ crowd-fixed.wsdl 2009-05-06 15:12:08.000000000 +0200 @@ -42,6 +42,10 @@ </xsd:complexType> </xsd:schema> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:SecurityServer"> +<xsd:import namespace="http://authentication.integration.crowd.atlassian.com"/> +<xsd:import namespace="http://soap.integration.crowd.atlassian.com"/> +<xsd:import namespace="http://exception.integration.crowd.atlassian.com"/> +<xsd:import namespace="http://rmi.java"/> <xsd:element name="findAllGroupRelationships"> <xsd:complexType> <xsd:sequence> @@ -642,6 +646,7 @@ </xsd:element> </xsd:schema> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://soap.integration.crowd.atlassian.com"> +<xsd:import namespace="urn:SecurityServer"/> <xsd:complexType name="ArrayOfSOAPNestableGroup"> <xsd:sequence> <xsd:element maxOccurs="unbounded" minOccurs="0" name="SOAPNestableGroup" nillable="true" type="ns2:SOAPNestableGroup"/>

            Hi,

            I'm attempting to make use of crowd's soap api via python. At present, this bug still remains an issue. The fix, as described above, is as simple as adding the following imports:

            <xsd:import namespace="http://authentication.integration.crowd.atlassian.com"/>
            <xsd:import namespace="http://soap.integration.crowd.atlassian.com"/>
            <xsd:import namespace="http://exception.integration.crowd.atlassian.com"/>
            <xsd:import namespace="http://rmi.java"/>

            under the urn:SecurityServer schema (note that two more imports are now required as compared to the above fix).

            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:SecurityServer">

            If a time frame could be provided for this fix it would be very much appreciated (looking at the history the last comment was over 2 years ago so it seems to have fallen under the radar .

            Thanks,

            Mike

            Mike Taylor added a comment - Hi, I'm attempting to make use of crowd's soap api via python. At present, this bug still remains an issue. The fix, as described above, is as simple as adding the following imports: <xsd:import namespace="http://authentication.integration.crowd.atlassian.com"/> <xsd:import namespace="http://soap.integration.crowd.atlassian.com"/> <xsd:import namespace="http://exception.integration.crowd.atlassian.com"/> <xsd:import namespace="http://rmi.java"/> under the urn:SecurityServer schema (note that two more imports are now required as compared to the above fix). <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="urn:SecurityServer"> If a time frame could be provided for this fix it would be very much appreciated (looking at the history the last comment was over 2 years ago so it seems to have fallen under the radar . Thanks, Mike

              Unassigned Unassigned
              ssmith Steve Smith (Inactive)
              Affected customers:
              5 This affects my team
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: