You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by William Mok <wm...@memotrax.com> on 2005/09/24 04:19:29 UTC

obtain remote ip address from soap

Hi,

I am using the messaging style in axis, hence writing a method called=20

process(SOAPEnvelpe req, SOAPEnvelope resp) can receive the soap message =
from the remote end.

However, I would like to know how I can obtain the remote IP address, =
i.e. the soap message sender ip addr.
Thanks.

William

Re: obtain remote ip address from soap

Posted by Christopher Johnson <jo...@gmail.com>.
A oneline fix as found in the FAQ

String remoteIP = msgContext.getStrProp(Constants.MC_REMOTE_ADDR);

..Chris

On 9/24/05, Soactive Inc <so...@gmail.com> wrote:
> I think the following code may work for you.
>
>  ---
>
>      org.apache.axis.MessageContext context =
> org.apache.axis.MessageContext.getCurrentContext();
>              Message message = context.getRequestMessage();
>
>              HttpServletRequest servletRequest = (HttpServletRequest)
>
> context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
>
>              String clientAddress = servletRequest.getRemoteAddr();
>              String clientHostName = servletRequest.getRemoteHost();
>
>  ---
>
>  -Arun
>
> On 9/23/05, William Mok <wm...@memotrax.com> wrote:
> >
> > Hi,
> >
> > I am using the messaging style in axis, hence writing a method called=20
> >
> > process(SOAPEnvelpe req, SOAPEnvelope resp) can receive the soap message =
> > from the remote end.
> >
> > However, I would like to know how I can obtain the remote IP address, =
> > i.e. the soap message sender ip addr.
> > Thanks.
> >
> > William
> >
>

Re: obtain remote ip address from soap

Posted by Soactive Inc <so...@gmail.com>.
I think the following code may work for you.

---

org.apache.axis.MessageContext context =
org.apache.axis.MessageContext.getCurrentContext();
Message message = context.getRequestMessage();

HttpServletRequest servletRequest = (HttpServletRequest)
context.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);

String clientAddress = servletRequest.getRemoteAddr();
String clientHostName = servletRequest.getRemoteHost();

---

-Arun

On 9/23/05, William Mok <wm...@memotrax.com> wrote:
>
> Hi,
>
> I am using the messaging style in axis, hence writing a method called=20
>
> process(SOAPEnvelpe req, SOAPEnvelope resp) can receive the soap message =
> from the remote end.
>
> However, I would like to know how I can obtain the remote IP address, =
> i.e. the soap message sender ip addr.
> Thanks.
>
> William
>