[Fedora-suds-list] Array confusion

Jeff Ortel jortel at redhat.com
Thu Jul 16 20:08:44 UTC 2009


The soap encoded (section 5) arrays are really stupid and are overly complex definitions 
for collections.

They are defined (basically) as:

<complexType>
   <sequence>
     <xs:any maxOccurs="unbounded"/>
   </sequence>
</complexType>

So, what you need to pass is a suds object that has an attribute with the value that is a 
python list|tuple.

You can do:

offer_array = self.client.factory.create('ns1:ArrayOfInt')
offer_array.item = [999,]

or

from suds.sudsobject import Object
offer_array = Object()
offer_array.item = [999,]

and it should work.  Or, at least it does with my axis servers.

The 'item' attribute is arbitrary.  Doesn't matter what you name it because it is defined 
as <xs:any/>

Hope this helps.

-jeff

William R. Dickson wrote:
> I apologize again for what is I'm sure a very basic question.
> 
> A service (is that the right term?) is listed as wanting the following:
> 
>     createEmailClient(ns1:ArrayOfInt offerIDs, xs:string emailDomain, 
> xs:string webmailHostname, )
> 
> This'll be my first attempt at a complex type, I guess. Although it's 
> asking for an array, there's only one value. I tried the following based 
> on some google searching:
> 
>     offer_array = self.client.factory.create('ns1:ArrayOfInt')
>     offer_array.offer = '9999'
>     print offer_array
>     self.client.service.createEmailClient(offerIDs=offer_array, 
> emailDomain=domain, webmailHostname=hostname)
> 
> This results in the following:
> 
> (ArrayOfInt){
>    _arrayType = ""
>    _offset = ""
>    _id = ""
>    _href = ""
>    offer = "9999"
>  }
> 
> ...followed by the following error:
> 
>   File "/Users/wrd/Scripts/mailthing3/Modules/ev1.py", line 57, in 
> Create_Client
>     self.client.service.createEmailClient(offerIDs=offer_array, 
> emailDomain=domain, webmailHostname=hostname)
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 240, in 
> __call__
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 379, in call
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 240, in 
> __call__
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 422, in call
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 480, in 
> invoke
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 511, in send
>   File "build/bdist.macosx-10.5-i386/egg/suds/client.py", line 562, in 
> failed
>   File "build/bdist.macosx-10.5-i386/egg/suds/bindings/binding.py", line 
> 227, in get_fault
> suds.WebFault: Server raised fault: 'java.lang.IllegalArgumentException: 
> argument type mismatch'
> 
> I assume I'm constructing the array incorrectly. Any suggestions would 
> be much appreciated.
> 
> Thanks,
> 
> -Bill
> 
> _______________________________________________
> fedora-suds-list mailing list
> fedora-suds-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-suds-list




More information about the fedora-suds-list mailing list