| 1 | = Converting Descriptions in SOAP to Python data structures = |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | 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: |
| 8 | |
| 9 | * [http://www.w3.org/TR/xmlschema11-2/#int xsd:int]: an integer value |
| 10 | * [http://www.w3.org/TR/xmlschema11-2/#string xsd:string]: a string value |
| 11 | * [http://www.w3.org/TR/xmlschema11-2/#boolean xsd:boolean]: a boolean value |
| 12 | * [http://www.w3.org/TR/xmlschema11-2/#base64Binary xsd:base64Binary]: an opaque binary value |
| 13 | * [http://www.w3.org/TR/xmlschema11-2/#dateTime xsd:dateTime]: an encoded date and time |
| 14 | * [http://www.w3.org/TR/xmlschema11-2/#float xsd:float]: a floating point value |
| 15 | * [http://www.w3.org/TR/xmlschema11-2/#double xsd:double]: a double precision floating point value |
| 16 | |
| 17 | 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. |
| 18 | |
| 19 | 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 [source:wsdl/trunk/fedd_types.xsd]) is described in xsd as: |
| 20 | {{{ |
| 21 | <xsd:complexType name="vtopolanType"> |
| 22 | <xsd:annotation> |
| 23 | <xsd:documentation> |
| 24 | LAN in the virtual topology of a federated experiment (Emulab legacy). |
| 25 | The fields are the name of the LAN/link (vname) the node that |
| 26 | this description applies to (vnode), the IP of the connection, |
| 27 | and performance information. |
| 28 | </xsd:documentation> |
| 29 | </xsd:annotation> |
| 30 | <xsd:sequence> |
| 31 | <xsd:element name="vname" type="xsd:string"/> |
| 32 | <xsd:element name="vnode" type="xsd:string"/> |
| 33 | <xsd:element name="ip" type="xsd:string"/> |
| 34 | <xsd:element name="bandwidth" type="xsd:int"/> |
| 35 | <xsd:element name="delay" type="xsd:float"/> |
| 36 | <xsd:element name="member" type="xsd:string"/> |
| 37 | </xsd:sequence> |
| 38 | </xsd:complexType> |
| 39 | }}} |
| 40 | |
| 41 | translates into a python dict like: |
| 42 | |
| 43 | {{{ |
| 44 | vlantopoType = { |
| 45 | 'vname': 'string', |
| 46 | 'vnode': 'string2', |
| 47 | 'ip': '10.1.1.1', |
| 48 | 'bandwidth': 100, |
| 49 | 'delay': 0.35, |
| 50 | 'member': 'member_string', |
| 51 | } |
| 52 | }}} |
| 53 | |
| 54 | }}} |