SOAPpy and ArrayOfKeyValue

A

Alex Ezell

Can anyone offer any assistance as to how to convert a basic python
dictionary, list, or even tuple into the SOAP type "ArrayOfKeyValue"?

I am currently using SOAPpy, but would be willing to change to ZSI or
something else if it made this conversion easier.

I have tried with the arrayType and structType methods in
SOAPpy.Types, yet they don't seem to do what I need. I suspect there
might not be just a single method call, so, I wrote something like
this:

def dictToKeyValue(self, mydict):
soap_list = []
for key,value in mydict.items():
inner = []
inner.append(SOAPpy.stringType(key,'key'))
inner.append(SOAPpy.stringType(value,'value'))
soap_list.append(SOAPpy.arrayType(inner))
print soap_list
return SOAPpy.arrayType(soap_list)

As you can see, it's pretty nasty and doesn't do what I need either. I
have a client that was written in PHP which I am converting. It uses
this function (which calls the PEAR SOAP library):

function assocArrayToKeyValue($array) {
$soap_array = array();
foreach($array as $key=>$value) {
$inner = array();
$inner[] =& new SOAP_Value('key', 'string', $key);
$inner[] =& new SOAP_Value('value', 'string', $value);
$soap_array[] =& new SOAP_Value("item",
"{{$this->wsdl_urn}}KeyValue", $inner);
}
return $soap_array;
}

Unfortunately, I don't really have a way to see exactly what
$soap_array is so that I could emulate it in my Python code.

Any pointers or suggestions are very much appreciated.

/alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

SOAPpy 0
Error with SOAPpy 0
SOAPpy help needed 1
SOAPpy port reuse 4
question about SOAPpy 1
SOAPpy and ArrayOfString 1
Python 3 dict question 12
Getting value of instances of variable. 1

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top