A fork of https://github.com/Synerty/SOAPpy-py3 This is a working tree till fixes get imported upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

72 lines
3.5 KiB

  1. Experimental method for handing ordered vs named method parameters
  2. ------------------------------------------------------------------
  3. There is an incompatibility with the way that Python and SOAP handle
  4. method arguments: SOAP requires that all arguments have names and that
  5. they are presented in the same order as the method signature. Python
  6. (like other scripting languages, notably the S language) has the
  7. concept of unnamed arguments. Further Python does not preserve the
  8. order of named arguments, since they are handled using the dictionary
  9. data type. It seems to me that this makes it impossible to fully meet
  10. the SOAP specification without significant modifications to the Python
  11. method of handling named arguments or to the Python dictionary class.
  12. Historically SOAPpy has attempted to work around this issue by
  13. handling all arguments as unnamed unless the method or function was
  14. explicitly flagged, in which case all arguments were considered named.
  15. This has resulted in a several problems, particularly for a SOAPpy
  16. client communicating with a SOAPpy server. First, when named
  17. arguments were used in call to a non-flagged function, the argument
  18. would silently be reordered by the sender (since they were stored
  19. using a Python dictionary), *and* the names would be ignored by the
  20. receiver, which assumed that the parameters were unnamed and only the
  21. order was significant. This results in incorrect argument matching.
  22. This problem also occurred with mixed named and unnamed arguments.
  23. For my primary SOAP application, it is not reasonable to flag all of
  24. the SOAPpy methods as requiring named arguments, for a variety of
  25. reasons. One reason is that the available methods are not known
  26. apriori by the client software, hence the names of the arguments are
  27. not known. Second, many of the methods provide a large number of
  28. optional arguments, making it impractical to specify them all.
  29. In an attempt to overcome this problem, I implemented an experimental
  30. and non-standard method of handling named and unnamed arguments. This
  31. mechanism is enabled in SOAPpy by setting
  32. SOAPpy.SOAP.Config.specialArgs=1, and disabled by setting
  33. SOAPpy.SOAP.Config.specialArgs=0.
  34. When enabled, parameters with names of the form v#### (i.e., matching
  35. the regexp "^v[0-9]+$") are assumed to be unnamed parameters and are
  36. passed to the method in numeric order. All other parameters are
  37. assumed to be named and are passed using the name. Outgoing SOAP
  38. method calls now always generate names in this way--whether or not
  39. specialArgs is enabled.
  40. I selected the form v#### because it is a valid XML name, but is
  41. unlikely to be used as a parameter name.
  42. [As it turns out, this choice was fortitous because Apache's SOAP tool
  43. uses the same system.]
  44. In my testing, this mechanism for handling method parameter names
  45. works fine between a SOAPpy client and a SOAPpy server, and resolves
  46. the parameter reordering problems I was experiencing. This system
  47. seems unlikely to have any negative side effects on other SOAP
  48. applications, except in the (hopefully) rare case when v#### might be
  49. used as an actual parameter name.
  50. **In version 0.9.9-pre1, this feature is enabled by default.** Please
  51. let me know if there are situations where this causes problems.
  52. Note that this mechanism is only a partial solution, since it is still
  53. impossible to return named parameters in a specified order using
  54. SOAPpy. SOAP applications or implementations which require this
  55. feature are simply not compatible with SOAPpy.
  56. -Greg Warnes <Gregory.R.Warnes@Pfizer.com>
  57. 2003-03-07 (updated 2003-11-14)