Version 1 (modified by 14 years ago) (diff) | ,
---|
Converting Descriptions in SOAP to Python data structures
The SOAP/xsd descriptions of fedd interfaces are portable across many programming languages and architectures, each with their own take on how to represent them internally. Because so much fedd code is written in python using the XSI package to encode and decode SOAP, we have placed some nodes on how to do the conversions.
The general layous of the files is that the message types are all in fedd_types.xsd while fedd.wsdl contains the SOAP boilerplate to turn it all into request/response messages. fedd_internal.wsdl is some internal fedd interfaces and topdl.xsd is the XSD defintions for topdl, fedd's topology description language.
Though the full details are described by the W3C in two documents, for fedd's purposes, the usage is simple enough. Messages are built up from simple XSD types composed into complex types. An element has a name and is part of a complex type and may either have a simple or complex type. Simple types in use by fedd include:
- xsd:int: an integer value
- xsd:string: a string value
- xsd:boolean: a boolean value
- xsd:base64Binary: an opaque binary value
- xsd:dateTime: an encoded date and time
- xsd:float: a floating point value
- xsd:double: a double precision floating point value
Each of these is encoded into python in the obvious ways. Doubles, floats and integers are python numbers; strings and base64Binaries are python strings; booleans are python variables set to True or False; and dateTimes are integers.
As simple element is encoded as a dictionary mapping between name and value. All the elements in the same sequence (an xsd grouping) are in the same dictionary. So, for example, the vtopolanType
complex type (from wsdl/trunk/fedd_types.xsd) is described in xsd as:
<xsd:complexType name="vtopolanType"> <xsd:annotation> <xsd:documentation> LAN in the virtual topology of a federated experiment (Emulab legacy). The fields are the name of the LAN/link (vname) the node that this description applies to (vnode), the IP of the connection, and performance information. </xsd:documentation> </xsd:annotation> <xsd:sequence> <xsd:element name="vname" type="xsd:string"/> <xsd:element name="vnode" type="xsd:string"/> <xsd:element name="ip" type="xsd:string"/> <xsd:element name="bandwidth" type="xsd:int"/> <xsd:element name="delay" type="xsd:float"/> <xsd:element name="member" type="xsd:string"/> </xsd:sequence> </xsd:complexType>
translates into a python dict like:
vlantopoType = { 'vname': 'string', 'vnode': 'string2', 'ip': '10.1.1.1', 'bandwidth': 100, 'delay': 0.35, 'member': 'member_string', }
}}}