Merhaba,

Python doesn't run generator functions until first iteration. The fix was to make sure header is processed *after* body in the soap protocol.

The latest commits from pull 141 fixes this, with a lot of other bugs mostly regarding html generation.

So if you use the latest code from arskom/rpclib repo, you should see the headers properly generated.

Let me know if you have any other issues.

Best,
Burak

On 06/06/12 16:13, Mehmet Arikkan wrote:
Hi Burak,

If I comment out the below _on_method_call and instead change say_hello function to this:

class HelloWorldService(ServiceBase):
    __out_header__ = RespHeader

    @rpc(Unicode, Integer, _returns=Iterable(Unicode))
    def say_hello(ctx, name, times):
        ctx.out_header = RespHeader()
        ctx.out_header.Elem1 = 'Test1'
        for i in range(times):
            yield u'Hello, %s' % name

I do not see Soap Header put in the message. Is this not a proper way?
How else can I introduce method specific headers?

On Mon, May 28, 2012 at 12:18 PM, Burak Arslan <[email protected] <mailto:[email protected]>> wrote:

    On 05/28/12 10:57, Mehmet Arikkan wrote:
    Hi Burak,

    I have found this answer as well, please don't bother :). I guess
    I have to use @rpc instead of @sprc so that I can include ctx
    variable. Please let me know if I am mistaken.


    Merhaba,

    Yes, you're correct. And in case you think I should make any
    additions to the documentation, please let me know.

    Best,
    Burak



    Regards,
    Mehmet

    On Mon, May 28, 2012 at 10:34 AM, Mehmet Arikkan
    <[email protected] <mailto:[email protected]>> wrote:

        Hi Burak,

        "You could also do it in the user code as well, without
        messing with events at all, in case you need to add
        method-specific headers."

        Could you please give an example about this method? This is
        what I need. I think I don't have a clear understanding on
        how I can use the "ctx" variable in an @rpc or @srpc
        decorator function.

        Suppose I have two methods A and B and I want to include an
        AHeader and a BHeader in them respectively. How can I do
        that, could you please elaborate with a simple example?

        Regards,
        Mehmet

        On Fri, May 25, 2012 at 9:14 PM, Burak Arslan
        <[email protected]
        <mailto:[email protected]>> wrote:

            On 05/25/12 21:09, Mehmet Arikkan wrote:
            Actually what I meant to ask is that whether my way to
            add the header is a proper way:

            def _on_method_call(ctx):
                ctx.out_header = RespHeader()
                ctx.out_header.Elem1 = 'Test1'
                ctx.out_header.Elem2 = 'Test2'

            HelloWorldService.event_manager.add_listener('method_call',
            _on_method_call)

            Is this how you would properly add a SOAP Header to your
            outgoing message?


            Yes, you could do it like this with events if you want to
            add that header to every response regardless of the
            method name. You could also do it in the user code as
            well, without messing with events at all, in case you
            need to add method-specific headers.

            Does that help?

            Best,
            Burak


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






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

Reply via email to