Skip to content

Commit

Permalink
Malformed Faults: introduces test for fault handler
Browse files Browse the repository at this point in the history
This initial patch introduces a test to demonstrate current fault
handling in the VmomiSupport and SoapAdapter components.

partial: vmware#72
  • Loading branch information
hartsock committed Jul 29, 2014
1 parent 297302c commit ce6dd69
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 12 deletions.
13 changes: 5 additions & 8 deletions pyVmomi/SoapAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,7 @@ def StartElementHandler(self, tag, attr):
if not self.stack:
if self.isFault:
ns, name = self.SplitTag(tag)
try:
objType = self.LookupWsdlType(ns, name[:-5])
except KeyError:
message = "{0} was not found in the WSDL".format(name[:-5])
raise VmomiMessageFault(message)
objType = self.LookupWsdlType(ns, name[:-5])
# Only top level soap fault should be deserialized as method fault
deserializeAsLocalizedMethodFault = False
else:
Expand Down Expand Up @@ -1257,12 +1253,13 @@ def InvokeMethod(self, mo, info, args, outerStub=None):
fd = GzipReader(resp, encoding=GzipReader.GZIP)
elif encoding == 'deflate':
fd = GzipReader(resp, encoding=GzipReader.DEFLATE)
obj = SoapResponseDeserializer(outerStub).Deserialize(fd, info.result)
except:
deserializer = SoapResponseDeserializer(outerStub)
obj = deserializer.Deserialize(fd, info.result)
except Exception as exc:
conn.close()
# The server might be sick, drop all of the cached connections.
self.DropConnections()
raise
raise exc
else:
resp.read()
self.ReturnConnection(conn)
Expand Down
5 changes: 1 addition & 4 deletions pyVmomi/VmomiSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,7 @@ def GuessWsdlType(name):
# in multiple namespaces, we will load the first type that we
# encounter and return it.
for ns in _wsdlTypeMapNSs:
try:
return GetWsdlType(ns, name)
except KeyError:
pass
return GetWsdlType(ns, name)
raise KeyError(name)

## Return a map that contains all the wsdl types
Expand Down
Loading

0 comments on commit ce6dd69

Please sign in to comment.