= 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 [source:wsdl/trunk files] is that the message types are all in [source:wsdl/trunk/fedd_types.xsd fedd_types.xsd] while [source:wsdl/trunk/fedd.wsdl fedd.wsdl] contains the SOAP boilerplate to turn it all into request/response messages. [source:wsdl/trunk/fedd_internal.wsdl fedd_internal.wsdl] is some internal fedd interfaces and [source:wsdl/trunk/topdl.xsd topdl.xsd] is the XSD defintions for [FeddPluginArchitecture#TopologyDescriptionLanguage topdl], fedd's topology description language. Though the full details are described by the W3C in [http://www.w3.org/TR/xmlschema11-1/ two] [http://www.w3.org/TR/xmlschema11-2/ 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: * [http://www.w3.org/TR/xmlschema11-2/#int xsd:int]: an integer value * [http://www.w3.org/TR/xmlschema11-2/#string xsd:string]: a string value * [http://www.w3.org/TR/xmlschema11-2/#boolean xsd:boolean]: a boolean value * [http://www.w3.org/TR/xmlschema11-2/#base64Binary xsd:base64Binary]: an opaque binary value * [http://www.w3.org/TR/xmlschema11-2/#dateTime xsd:dateTime]: an encoded date and time * [http://www.w3.org/TR/xmlschema11-2/#float xsd:float]: a floating point value * [http://www.w3.org/TR/xmlschema11-2/#double 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}}} and {{{vtoponodeType}}} complex types (from [source:wsdl/trunk/fedd_types.xsd]) are described in xsd as: {{{ Node in the visualization of a federated experiment (Emulab legacy). Fields include the local hostname of the node, x,y coordinates in a 2-dimensional representation, and whether the node in the visualization is a host or a LAN. 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. }}} translate into python dicts like: {{{ vtoponodeType = { 'vnode': 'name', 'ips': '10.1.1.1,10.1.2.1', } vtopolanType = { 'vname': 'string', 'vnode': 'string2', 'ip': '10.1.1.1', 'bandwidth': 100, 'delay': 0.35, 'member': 'member_string', } }}} A complex type that includes another element that is a sequence simply includes a dict keyed by the element name. Some elements are repeated multiple times in a type, or are optional, as noted by the {{{maxOccurs}}} and {{{minOccurs}}} attributes. Elements that have {{{maxOccurs="1"}}} and {{{minOccurs="0"}}} defined in the XSD are optional fields and may either occur in the sequence/dict or not. Elements with {{{maxOccurs="unbounded"}}} and {{{minOccurs="0"}}} defined in the XSD are repeated elements. If none appear, the key is missing from the dict, if one or more are present the value mapped to the element name in the dict is a list of hashes, one for each copy of the repeatable element present. For example, the {{{vtopoType}}} from [source:wsdl/trunk/fedd_types.xsd fedd_types.xsd] includes a pair of repeated elements. It is defined in XSD as: {{{ The virtual topology of a federated experiment (Emulab legacy). }}} An example of that datatype that only