[Soap-Python] how to fetch client's IP Address in soap method?

Japan Shah shahjapan at gmail.com
Wed Aug 10 08:24:13 CEST 2011


Not Worked for me,
I'm using SoapLib 2.0 beta

On 9 August 2011 23:58, Michael Wood <esiotrot at gmail.com> wrote:

> Hi
>
> On 9 August 2011 12:23, Dieter Maurer <dieter at handshake.de> 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 <esiotrot at gmail.com>
>



-- 
#Japan Shah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/soap/attachments/20110810/fa99861c/attachment-0001.html>


More information about the Soap mailing list