arskom / spyne

A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
http://spyne.io
Other
1.13k stars 313 forks source link

allow more control over generated WSDL #274

Open FelixSchwarz opened 11 years ago

FelixSchwarz commented 11 years ago

I found that I'm unable to reimplement a given WSDL using spyne because even after building the required classes by hand spyne has some defaults hard-coded which don't match my WSDL. I think ultimately we need a way to hook into the WSDL/schema generation from the outside.

A simple example is elementFormDefault in XmlSchema.get_schema_node() (spyne.interface.xml_schema._base). My WSDL must set this to unqualified.

The main problem seems to be how you are using the event manager. I found it highly confusing that there are multiple EventManager instances and I think as a first step the API should be changed so that there is only a single event manager instance.

I could provide patches but I need some hints about architectural style of such a callback/extension/plugin system.

plq commented 11 years ago

Hi,

In Spyne, interface document generation is done in two steps:

  1. Application generates the generic Interface object on instantiation.
  2. Transport generates separate interface documents when appropriate.

The Wsdl 1.1 document is generated by spyne.interface.wsdl.Wsdl11 class. The ServerBase class stores interface documents in self.doc and the Wsdl 1.1 document in self.doc.wsdl11.

It's not possible to pass options to InterfaceDocument children but it's possible to override options once instantiated. E.g.:


wsgi_app = WsgiApplication(...)
wsgi_app.doc.wsdl11.element_form_default = 'unqualified`

This is currently the canonical way of doing it. It'd work because Wsdl11 documents are generated on first request, when there's a URL at hand to put inside the document. See: http://stackoverflow.com/questions/16658888/override-wsdl-port-i-e-bound-url-in-spyne

So if you could send a patch that makes the above work (with tests), i'd be happy to merge it.

I couldn't decide on a way of passing parameters to interface documents on transport instantiation. Any ideas? The best I have in mind right now is:

wsgi_app = WsgiApplication(app, wsdl11=Wsdl11(element_form_default='unqualified'))
mnacharov commented 10 years ago

Hello guys! I just found this RPC-framework and really like it, because I can write one service and easily provide many protocols to it. But I can't change number of provided methods for particular IP, right?

plq commented 10 years ago

please use http://lists.spyne.io/listinfo/people for questions

PyGuDev commented 3 years ago

Hello, how can I add elementFormDefault = "unqualified" attribute to wsdl schema?