Skip to content

Commit

Permalink
Undocumented Faults incorrectly de-serialize
Browse files Browse the repository at this point in the history
example: LicenseUsageFault
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>ServerFaultCode</faultcode>
      <faultstring/>
      <detail>
        <LicenseUsageFaultFault xsi:type="LicenseUsageFault">
           <reason>dataTampered</reason></LicenseUsageFaultFault>
      </detail>
    </soapenv:Fault>

The detail tag's first child represents the data type to unmarshal the Fault message envelope's contents into. If that child tag does not have a matching WSDL definition pyVmomi fails to raise the fault.

This change lets the library dynamically create the new fault data type at runtime.

closes vmware#72
  • Loading branch information
hartsock committed Jul 17, 2014
1 parent 75f11ce commit 8659a12
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyVmomi/SoapAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,15 @@ def StartElementHandler(self, tag, attr):
if not self.stack:
if self.isFault:
ns, name = self.SplitTag(tag)
objType = self.LookupWsdlType(ns, name[:-5])
try:
objType = self.LookupWsdlType(ns, name[:-5])
except:
fault_name = name[:-5]
vmodl_name = "vmodl.fault." + fault_name
CreateDataType(str(vmodl_name), str(fault_name),
"vmodl.RuntimeFault", "vmodl.version.version0",
None)
objType = self.LookupWsdlType(ns, fault_name)
# Only top level soap fault should be deserialized as method fault
deserializeAsLocalizedMethodFault = False
else:
Expand Down

1 comment on commit 8659a12

@hartsock
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is controversial I think the controversy should be over my use of CreateDataType in this context. I am wholly ignoring the WSDL and generating a new data type on the fly. This is a clear violation of client-server contract and ideally should never happen. But, what's the alternative?

  1. do nothing
  2. do this
  3. do something else?

What else?

Please sign in to comment.