kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

A list of dicts in a dict does not return anything #90

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am trying to return a structure from my server that would look like the 
following:
{'QueueElements': [
    {'Element': 
        {'CQ': str, 'ID': int, 'Name': str}
    }, 
    {'Element': 
        {'CQ': str, 'ID': int, 'Name': str}
    }, 
    ...
], 
'StatusCode': int}

I've tried other formats but Issue #30 suggested using this format so I've 
moved to that but I've always received {QueueElements is None, StatusCode is 
int}.  I'm not sure what else to change so I'm assuming there is some problem.  

I'm using 1.05a of pysimplesoap on 2.6.6 on RHEL6.2

Other info on my current setup
----------------------------------------------------------------

I have the following command set up (simply lists queue items on the server)
# on the server
# set up my call in an init routine
    self._dispatcher.register_function('list', self.list,
            returns={'StatusCode': int, 'QueueElements':
                [{'Element': {'ID': str, 'CQ': str, 'Name': str}}]},
            args={})

# the actual call
    def list(self):
        '''Returns a list of all queued items'''

        rtn = {'StatusCode': 42, 'QueueElements': []}

        # let everyone know we are working on the queue
        with self._hold:
            for task in self.test_run_queue:
                qe = {'Element':
                        {'ID': task.id,
                         'CQ': task.cqid,
                         'Name': task.name}}
                rtn['QueueElements'].append(qe)

        self._logger.info(rtn)
        return rtn

#on client
        resp = self._client.list(arg1=1, arg2=2)
        self._logger.info(resp.StatusCode)
        if(resp['QueueElements'] is None):
            self._logger.info('Appears as though there are no queued items')
            return

# and then the trace info
--------------------------------------------------------------------------------
POST http://127.0.0.1:8008/webservices/sample/call/soap
SOAPAction: "http://127.0.0.1:8008/webservices/sample/call/soaplist"
Content-length: 375
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
    <list xmlns="http://127.0.0.1:8008/webservices/sample/call/soap">
    <arg1>1</arg1><arg2>2</arg2></list>
</soap:Body>
</soap:Envelope>
date: Thu, 17 Jan 2013 17:19:55 GMT
status: 200
content-type: text/xml
server: BaseHTTP/0.3 Python/2.6.6
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><listResponse 
xmlns="http://example.com/sample.wsdl"><QueueElements><Element><CQ>SCGCQ00364573
</CQ><ID>0</ID><Name>some random 
name</Name></Element><Element><CQ>SCGCQ00364573</CQ><ID>1</ID><Name>another 
random name</Name></Element><Element><CQ>SCGCQ00364573</CQ><ID>2</ID><Name>yet 
another random 
name</Name></Element></QueueElements><StatusCode>42</StatusCode></listResponse><
/soap:Body></soap:Envelope>
================================================================================

# and the output from the server
2013-01-17 11:19:55,659 - ATE2 - INFO - {'QueueElements': [{'Element': {'CQ': 
u'SCGCQ00364573', 'ID': 0, 'Name': u'some random name'}}, {'Element': {'CQ': 
u'SCGCQ00364573', 'ID': 1, 'Name': u'another random name'}}, {'Element': {'CQ': 
u'SCGCQ00364573', 'ID': 2, 'Name': u'yet another random name'}}], 'StatusCode': 
42}

# the output from the cli
2013-01-17 11:19:55,665 - ATE2 - INFO - 42    <--- this is the statuscode that 
I returned
2013-01-17 11:19:55,665 - ATE2 - INFO - Appears as though there are no queued 
items  <---- this was from the test on QueueElements is None

Original issue reported on code.google.com by diabelek on 17 Jan 2013 at 5:34

GoogleCodeExporter commented 8 years ago
please close, found the issue.  apparently can't use resp['QueueElements'] and 
need to use resp.QueueElements.  Also, needed to the individual items from the 
list of dictionarys by doing:
self._logger.info('%# 4d. %s - %s' % (ret.Element[i].ID, ret.Element[i].CQ, 
ret.Element[i].Name))

Original comment by diabelek on 17 Jan 2013 at 9:52

GoogleCodeExporter commented 8 years ago

Original comment by reingart@gmail.com on 29 Aug 2013 at 9:05