python-zeep icon indicating copy to clipboard operation
python-zeep copied to clipboard

Nested 'item' absent

Open danisabad opened this issue 10 years ago • 2 comments

I'm trying to get data from SevOne SOAP api using zeep 0.20.0 and faced a problem.

Using php SoapClient I got this request body (all is working fine):

        <dataSources SOAP-ENC:arrayType="ns1:SO_GraphDataSource[1]" xsi:type="ns1:ArrayOfSO_GraphDataSource">
          <item xsi:type="ns1:SO_GraphDataSource">
            <deviceId xsi:type="xsd:integer">XXX</deviceId>
            <plugin xsi:type="xsd:string">XXX</plugin>
            <objectName xsi:type="xsd:string">XXX</objectName>
            <indicator xsi:type="xsd:string">XXX</indicator>
          </item>
        </dataSources>

But when I'm using zeep, I've got following request body:

        <dataSources xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ns1:arrayType="ns1:SO_GraphDataSource[0]" xsi:type="ns1:ArrayOfSO_GraphDataSource">
          <deviceId>XXX</deviceId>
          <plugin>XXX</plugin>
          <objectName>XXX</objectName>
          <indicator>XXX</indicator>
        </dataSources>

See, no 'item' wrap-up here. And when I send this XML back to server, I got wrong results.

Code:

graph = service.factory_Graph()

This is the returned SO_Graph object:

{
    'graphType': 'graph_line',
    'size': 1,
    'percentageEnabled': 0,
    'scaledEnabled': 1,
    'bitsOrBytes': 'bits',
    'displayType': 'total',
    'percentileEnabled': 0,
    'percentile': 95,
    'showSummary': 0,
    'workHoursEnabled': 0,
    'workHours': '0',
    'timeOverTimeEnabled': 0,
    'timeOverTimeAggregation': 'average',
    'timeOverTimeNumber': 0,
    'timeOverTimeUnits': 'day',
    'timeOverTimeOnly': 0,
    'granularityEnabled': 0,
    'granularityAggregation': 'average',
    'granularitySeconds': 0,
    'dataSources': {
        '_value_1': [],
        'arrayType': 'ns1:SO_GraphDataSource[0]',
        'offset': None,
        'id': None,
        'href': None,
        '_attr_1': {
            '{http://www.w3.org/2001/XMLSchema-instance}type': 'ns1:ArrayOfSO_GraphDataSource'
        }
    }
}

Fill dataSource field:

data_source = service.factory_GraphDataSource()
graph['dataSources']['_value_1'].append(data_source)

Modified object:

...
    'dataSources': {
        '_value_1': [
            {
                'deviceId': 'XXX',
                'plugin': 'XXX',
                'objectName': 'XXX',
                'indicator': 'XXX'
            }
        ],
        'arrayType': 'ns1:SO_GraphDataSource[0]',
...

This is the end command where I pass SO_Graph object:

report_makeUrlFromGraph(graph: SO_Graph, timespan: SO_Timespan, trend: SO_Trend, ipAddress: xsd:string) -> body: {return: xsd:string}, header: {}

Thanks in advance.

danisabad avatar Oct 28 '16 16:10 danisabad

This might be fixed in master now (see #232 )

mvantellingen avatar Oct 28 '16 19:10 mvantellingen

Closing for now, let me know if it still is an issue

mvantellingen avatar Nov 06 '16 16:11 mvantellingen