Hi,

One of my soap method needs to generate a header and here is what my code looks like:

EWS_T_NS = "http://schemas.microsoft.com/exchange/services/2006/types";

class ServerVersionInfo(ComplexModel):
    __namespace__ = EWS_T_NS
    _type_info = {"MajorVersion": XmlAttribute(Integer),
                  "MinorVersion": XmlAttribute(Integer),
                  "MajorBuildNumber": XmlAttribute(Integer),
                  "MinorBuildNumber": XmlAttribute(Integer)}


class ExchangeService(ServiceBase):
@rpc(SerializableTimeZone,ArrayOfMailboxData,FreeBusyViewOptions,SuggestionsViewOptions,
         _in_message_name="GetUserAvailabilityRequest",
         _out_header=ServerVersionInfo,
         _returns=(ArrayOfFreeBusyResponse,SuggestionsResponseType),
_out_variable_names=("FreeBusyResponseArray", "SuggestionsResponse"),
  ....

However, this systematically outputs:

<senv:Header>
<tns:ServerVersionInfo MajorVersion="8" MinorBuildNumber="24" MinorVersion="0" MajorBuildNumber="685"/>
</senv:Header>

where "xmlns:tns="http://schemas.microsoft.com/exchange/services/2006/messages";.

After deep inspection, it seems the bug is in soap11.py, where the default application tns is always requested. Here is a patch that fixes it and request the namespace from the header element class instead.

--- soap11.py~    2012-05-01 14:23:54.000000000 -0400
+++ soap11.py    2012-05-02 12:54:57.445587367 -0400
@@ -277,14 +277,14 @@
out_headers):
                             self.to_parent_element(header_class,
                                 out_header,
-                                self.app.interface.get_tns(),
+                                header_class.get_namespace(),
                                 soap_header_elt,
                                 header_class.get_type_name(),
                             )
                     else:
                         self.to_parent_element(header_message_class,
                             ctx.out_header,
-                            self.app.interface.get_tns(),
+                            header_message_class.get_namespace(),
                             soap_header_elt,
                             header_message_class.get_type_name()
                         )


This indeed fixes my output. Does this seem reasonable?



Wolfgang



_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap

Reply via email to