Appreciate the response. I think that the problem was with my SUDS version…my server is
locked into 3.9--in 4.0 this problem is gone (and you can specify a value for a
ComplexType).
On 3.9 my workaround took the following form:
from suds.sudsobject import Property
client = Client(wsdl)
values = client.factory.create('ArrayOfTimedValue')
for time, data in information.items():
value = Property(data)
value._Path = path
value._PctGood = 0.0
value._Time = self.time_format(float(time), offset)
values.TimedValue.append(value)
As I read it, you have to start from the value, then add the metadata manually and the
resulting object looks like the one suds would have automatically created.
Now if I can just figure out why my the datetimes in my return values are being offset by
2 hours I would be a happy man.
JR
On Sep 24, 2012, at 1:34 PM, Matthew Ashton wrote:
All right, so you don't want to assign TimedValue to a value
explicitly? I believe SUDS generates the empty XML element because that element has no
value.
So you would need to define a default value for TimedValue to be zero, I would guess. I
googled for how to add an initial value to an element in a WSDL definition... and it seems
within the element you put the "default" attribute and set it to
"0"..
This is the element definition ->
<xs:element minOccurs="0" maxOccurs="unbounded"
name="TimedValue"
nillable="true" type="tns:TimedValue"/>
so I would think it would be like
<xs:element minOccurs="0" maxOccurs="unbounded"
name="TimedValue"
nillable="true" default="0" type="tns:TimedValue"/>
unless it needs to be defined within the complexType itself where the attributes for the
element are defined.
I'm not too familiar with WSDL so, idk.
Hope this helps, and if you can clarify the problem more... then I'll try to help
more as well :)
-mag
On Mon, Sep 17, 2012 at 3:15 PM, JR Powers-Luhn <jrpowersluhn(a)intercap-e.com>
wrote:
All
Looking for some direction as I can't seem to get out using Google +
Documentation
I am using a service described (in part) by the WSDL snip below:
<xs:complexType name="ArrayOfTimeSeries">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="TimeSeries"
nillable="true" type="tns:TimeSeries"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TimeSeries">
<xs:complexContent mixed="false">
<xs:extension base="tns:DataItem">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1"
name="TimedValues"
nillable="true" type="tns:ArrayOfTimedValue"/>
</xs:sequence>
<xs:attribute name="Path" type="xs:string"/>
<xs:attribute name="ErrDesc" type="xs:string"/>
<xs:attribute name="Error" type="xs:int"
use="required"/>
<xs:attribute name="SeriesID" type="xs:string"/>
<xs:attribute name="DataType" type="xs:string"/>
<xs:attribute name="UOM" type="xs:string"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DataItem" abstract="true"/>
<xs:complexType name="ArrayOfTimedValue">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded"
name="TimedValue"
nillable="true" type="tns:TimedValue"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="TimedValue">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Path" type="xs:string"/>
<xs:attribute name="Flags" type="xs:string"/>
<xs:attribute name="Time" type="xs:dateTime"
use="required"/>
<xs:attribute name="UOM" type="xs:string"/>
<xs:attribute name="Status" type="xs:string"/>
<xs:attribute name="PctGood" type="xs:double"/>
<xs:attribute name="DataType" type="xs:string"/>
</xs:extension></xs:simpleContent>
</xs:complexType>
<xs:element name="InsertPIData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="events"
type="tns:ArrayOfTimeSeries"/>
<xs:element minOccurs="1" maxOccurs="1"
name="duplicateSwitch">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="InsertDuplicate"/>
<xs:enumeration value="ReplaceDuplicate"/>
<xs:enumeration value="ReplaceOnlyDuplicate"/>
<xs:enumeration value="ErrorDuplicate"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
The problem is when I construct a TimedValue
>>> value=client.factory.create('TimedValue')
>>> print value
(TimedValue){
_Path = ""
_Flags = ""
_Time = ""
_UOM = ""
_Status = ""
_PctGood = ""
_DataType = ""
}
>>>
The XML I need to output is something like:
<events>
<TimeSeries DataType="xs:float" Error="0"
Path="pi:\\pi.intercap-server.com\IUE-001-AHU-1.ControlMode">
<TimedValues>
<TimedValue Path="pi:\\pi.intercap-server.com\IUE-001-AHU-1.ControlMode"
PctGood="0.0" Time="2012-09-14T00:26:21Z">0</TimedValue>
</TimedValues>
</TimeSeries>
</events>
<duplicateSwitch>ReplaceDuplicate</duplicateSwitch>
</InsertPIData>
but instead I'm outputting:
<events>
<TimeSeries DataType="xs:float" Error="0"
Path="pi:\\pi.intercap-server.com\IUE-001-AHU-1.ControlMode">
<TimedValues>
<TimedValue Path="pi:\\pi.intercap-server.com\IUE-001-AHU-1.ControlMode"
PctGood="0.0" Time="2012-09-14T00:26:21Z" />
</TimedValues>
</TimeSeries>
</events>
<duplicateSwitch>ReplaceDuplicate</duplicateSwitch>
</InsertPIData>
How can I insert a value for the TimedValue besides the attributes? I
found a thread that seems related here, but it doesn't seem to have
been resolved:
http://lists.fedoraproject.org/pipermail/suds/2010-April/000825.html
Any help appreciated
_______________________________________________
suds mailing list
suds(a)lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/suds
<ATT00001.c>