[spyne] defining a service without expecting namespace in every tag

Burak Arslan burak.arslan at arskom.com.tr
Tue Aug 11 16:17:29 UTC 2015


Finally I got some time!

On 08/11/15 17:24, Daniele Bortoluzzi wrote:
> Removing the overridden call_wrapper() from my code does the job,
> because the "unpacking problem" is correctly managed in the original
> Application.call_wrapper():
>         if ctx.descriptor.body_style is BODY_STYLE_BARE:
>             ctx.in_object = [ctx.in_object]
>         elif ctx.descriptor.body_style is BODY_STYLE_EMPTY:
>             ctx.in_object = []

Having this logic inside the call_wrapper is a mistake. It should be in
process_request. I moved it there.

> According to the Spyne manual ("How Exactly is User Code Wrapped?")
> ServiceBase.call_wrapper() is called *after*
> Application.call_wrapper(), so when you override this function you
> must be sure that there are no unpacking issues, right?

ServiceBase.call_wrapper() is called by Application.call_wrapper(), not
after. Both only accept context objects, and context objects' contents
should be in the documented format. For in_object and out_object, that's
"sequence of objects". It was my mistake to put the wrapped/bare logic
inside call_wrapper() a user-overridable function, which meant sometimes
passing 'invalid' data to call_wrapper.

Sorry for this confusion and thanks a lot for bringing this up!

On 08/10/15 20:54, Daniele Bortoluzzi wrote:
> On 10 August 2015 at 19:13, Burak Arslan <burak.arslan at arskom.com.tr
> <mailto:burak.arslan at arskom.com.tr>> wrote:
>     On 08/10/15 19:47, Daniele Bortoluzzi wrote:
>     [...]
> First of all, sorry for top-posting in the previous message :(

Hey, thanks for your courtesy, appreciated.

>     sorry, that's not what I meant.
>     In the document that is produced by "their" client, is there an
>     xmlns="something" (not xmlns:ns1="Something", only xmlns="Something")
> No, there isn't. the SOAP-ENV tag of "their" message is the same as
> "mine".
>     Spyne does not like undefined namespaces. I think the reason for
>     it was my not being able to figure out the schema document to
>     validate an undefined namespace.
> Their message seems well-formed, the question is: if I define a
> service in Spyne, must every tag of the input message contain a namespace?

Yes. You can override the nsmap of an application
(application.interface.nsmap) before generating the wsdl document and
assign the null prefix to a namespace, but you always have to have a
namespace. I'd be happy to accept patches that lift this limitation.

> Once I have set up a namespace in the parent element, why does every
> child contain the same NS?

It doesn't have to, you already know about sub_ns

> Setting an empty __namespace__ or sub_ns attribute has no effect
> because you also check for zero-length strings.

Yes, that protects you from errors while building the xml schema.

>     if you got issues with namespaces, try soft validation.
> This could be the fastest solution.
>     if nothing works, you can set up a before_deserialize event on
>     your input protocol to use string methods to replace unwanted
>     namespace prefixes. yes, it's disgusting but it'll work :)
> Well, I have the opposite problem: the Spyne WS expects a namespace in
> every tag so I should *add* a namespace wherever "their" message lacks
> it. Yeah, mangling the input message is disgusting :)

Of course, sorry about that. Perhaps I meant to say: "If you could
somehow add a null-prefix namespace declaration to the incoming
document, that'd work too."

I hope this helps.

best regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spyne.io/archives/people/attachments/20150811/3e105812/attachment.html>

More information about the people mailing list