Re: SOAPpy and ArrayOfKeyValue

Discussion in 'Python' started by Alex Ezell, Oct 9, 2007.

  1. Alex Ezell

    Alex Ezell Guest

    It's cool when you solve your own problems. It was as simple as this:

    def dictToKeyValue(self, mydict):
    soap_list = []
    for key,value in mydict.items():
    inner = {"key":key,"value":value}
    soap_list.append(inner)
    return soap_list

    It's just a list of dictionaries with the actual words "key" and
    "value" as keys in the dictionary. I was making it much harder than it
    needed to be.

    SOAPpy is smart enough to handle the rest. Thanks SOAPpy!

    /alex

    On 10/9/07, Alex Ezell <> wrote:
    > 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
    >
     
    Alex Ezell, Oct 9, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Bell
    Replies:
    0
    Views:
    292
    Steven Bell
    Oct 9, 2003
  2. Lyle
    Replies:
    0
    Views:
    363
  3. Vivek
    Replies:
    0
    Views:
    2,559
    Vivek
    Aug 4, 2004
  4. Richard Kessler

    SOAPpy and .NET - Help

    Richard Kessler, Nov 1, 2004, in forum: Python
    Replies:
    1
    Views:
    325
    Stefan Behnel
    Nov 3, 2004
  5. Alex Ezell

    SOAPpy and ArrayOfKeyValue

    Alex Ezell, Oct 9, 2007, in forum: Python
    Replies:
    0
    Views:
    372
    Alex Ezell
    Oct 9, 2007
Loading...

Share This Page