Esempio n. 1
0
    def build_interface_document(self, url):
        super(BaseSmevWsdl, self).build_interface_document(url)
        smev_schema = self._get_smev_schema().getroot()
        smev_schema = _utils.copy_with_nsmap(
            smev_schema, dict(tns=self._ns["tns"]))

        messages = self.root_elt.xpath(
            "./wsdl:portType/wsdl:operation/wsdl:input/@message | "
            "./wsdl:portType/wsdl:operation/wsdl:output/@message",
            namespaces=self._ns)
        messages = tuple(message.split(':') for message in messages)
        for _, message in messages:
            self._create_message_schema(smev_schema, message)

        tns_schema = self.root_elt.find(
            "./{{{wsdl}}}types/{{{xs}}}schema[@targetNamespace='{tns}']"
            .format(**self._ns))
        new_tns_schema = _utils.copy_with_nsmap(
            tns_schema, {'smev': self.smev_ns})

        # importing smev schema into tns, required
        # for compatibility with suds client
        new_tns_schema.insert(0, _etree.Element(
            "{{{xs}}}import".format(**self._ns), namespace=self.smev_ns))

        for _, message in messages:
            element = new_tns_schema.find(
                './/{{{0}}}element[@name="{1}"]'.format(_ns.xs, message))
            element.attrib['type'] = 'smev:{0}Type'.format(message)

        self.root_elt.find(
            "./{{{0}}}types".format(_ns.wsdl)).insert(0, smev_schema)
        tns_schema.getparent().replace(tns_schema, new_tns_schema)

        import_xop_include = smev_schema.find(
            "{{{0}}}import"
            "[@namespace='http://www.w3.org/2004/08/xop/include']"
            .format(_ns.xs)
        )
        if import_xop_include is not None:
            import_xop_include.attrib.pop("schemaLocation")
            xop_include_schema = _utils.load_xml(
                os.path.join(
                    os.path.dirname(__file__), "xsd", "xop-include.xsd")
            ).getroot()
            self.root_elt.find("./{{{0}}}types".format(_ns.wsdl)).insert(
                0, xop_include_schema)

        self._add_smev_headers(self.root_elt)
        self._Wsdl11__wsdl = _etree.tostring(
            self.root_elt, encoding='UTF-8')
Esempio n. 2
0
    def build_interface_document(self, url):
        super(BaseSmevWsdl, self).build_interface_document(url)
        smev_schema = self._get_smev_schema().getroot()
        smev_schema = _utils.copy_with_nsmap(smev_schema,
                                             dict(tns=self._ns["tns"]))

        messages = self.root_elt.xpath(
            "./wsdl:portType/wsdl:operation/wsdl:input/@message | "
            "./wsdl:portType/wsdl:operation/wsdl:output/@message",
            namespaces=self._ns)
        messages = tuple(message.split(':') for message in messages)
        for _, message in messages:
            self._create_message_schema(smev_schema, message)

        tns_schema = self.root_elt.find(
            "./{{{wsdl}}}types/{{{xs}}}schema[@targetNamespace='{tns}']".
            format(**self._ns))
        new_tns_schema = _utils.copy_with_nsmap(tns_schema,
                                                {'smev': self.smev_ns})

        # importing smev schema into tns, required
        # for compatibility with suds client
        new_tns_schema.insert(
            0,
            _etree.Element("{{{xs}}}import".format(**self._ns),
                           namespace=self.smev_ns))

        for _, message in messages:
            element = new_tns_schema.find(
                './/{{{0}}}element[@name="{1}"]'.format(_ns.xs, message))
            element.attrib['type'] = 'smev:{0}Type'.format(message)

        self.root_elt.find("./{{{0}}}types".format(_ns.wsdl)).insert(
            0, smev_schema)
        tns_schema.getparent().replace(tns_schema, new_tns_schema)

        import_xop_include = smev_schema.find(
            "{{{0}}}import"
            "[@namespace='http://www.w3.org/2004/08/xop/include']".format(
                _ns.xs))
        if import_xop_include is not None:
            import_xop_include.attrib.pop("schemaLocation")
            xop_include_schema = _utils.load_xml(
                os.path.join(os.path.dirname(__file__), "xsd",
                             "xop-include.xsd")).getroot()
            self.root_elt.find("./{{{0}}}types".format(_ns.wsdl)).insert(
                0, xop_include_schema)

        self._add_smev_headers(self.root_elt)
        self._Wsdl11__wsdl = _etree.tostring(self.root_elt, encoding='UTF-8')
Esempio n. 3
0
 def _get_smev_schema(self):
     self.__smev_schema = self.__smev_schema or _utils.load_xml(
         self.smev_schema_path)
     return self.__smev_schema
Esempio n. 4
0
 def _get_smev_schema(self):
     self.__smev_schema = self.__smev_schema or _utils.load_xml(
         self.smev_schema_path)
     return self.__smev_schema