Hi

On 9 August 2011 12:23, Dieter Maurer <[email protected]> wrote:
> Japan Shah wrote at 2011-8-9 14:43 +0530:
>>   can anyone has idea how to retrieve the client's IP Address in exposed
>>soap method ?
>>any help or link for such example would be appreciated !
>
> SOAP itself is transport independent and therefore does not know
> anything about IP adresses.
>
> Therefore, it depends on your (lower level) web framework and its
> transport layer how you can access the IP address.
>
>
> To get more precise information, you must tell us
> which web framework and which SOAP framework you are using.

Thanks, Dieter.  With the above hints I was able to figure it out.

I added an __init__() method to my service as follows:

class MyService(DefinitionBase):

    def __init__(self, environ=None):
        self.environ = environ or {}
        DefinitionBase.__init__(self, environ)

and then I can access the client's IP as follows:

    @rpc(_returns=String)
    def Info(self):
        client = self.environ.get("REMOTE_ADDR", "(unknown)")
        logging.info("[%s] Called Info()", client)
        info = "SOAP Service"
        return info

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

Reply via email to