Ejemplo n.º 1
0
def soap_api():
    """
    SOAP web service documentation by rendering the WSDL document as HTML.

    Generate the documentation by a XSL transform of the WSDL document.
    The XSL transformation used is `WSDL viewer
    <http://tomi.vanek.sk/index.php?page=wsdl-viewer>`_ by Tomi Vanek.

    We apply a small patch to this transformation to show newlines in
    the SOAP method docstrings:

    1. Around line 1195, the description ``<div>``, replace
       ``<div class="value">`` by ``<div class="value documentation">``.

    2. In the style sheet, add:

           .documentation { white-space: pre-line; }
    """
    soap_server = HttpBase(soap.application)
    soap_server.doc.wsdl11.build_interface_document(
        settings.SOAP_WSDL_URL or 'https://mutalyzer.nl/services/?wsdl')
    wsdl_string = soap_server.doc.wsdl11.get_interface_document()

    xsl_file = os.path.join(
        pkg_resources.resource_filename('mutalyzer', 'website/templates'),
        'wsdl-viewer.xsl')
    wsdl_doc = etree.fromstring(wsdl_string)
    xsl_doc = etree.parse(xsl_file)
    transform = etree.XSLT(xsl_doc)

    return make_response(unicode(transform(wsdl_doc)))
Ejemplo n.º 2
0
 def _getServer(self):
   try:
     serial, server = self._v_server
     if serial == self._p_serial:
       return server
   except AttributeError:
     pass
   server = HttpBase(Application(
     map(self._service_class_dict.__getitem__, self.getServiceClassList()),
     self.getTargetNamespace(),
     in_protocol=Soap11(), out_protocol=Soap11()))
   self._v_server = self._p_serial, server
   return server