Beauty is in the eye of the beholder, same goes for elegance. 
You could probably append the IP information to the incoming message
using CXF, maybe there are other options, I am not a CXF expert. 

As you are not willing to expose this functionality as part of you
public interface (WSDL), most (all?) solutions will have a hacky feeling
to them.

-- david




-----Original Message-----
From: Yair Ben-Meir [mailto:[EMAIL PROTECTED] 
Sent: 16 July 2008 14:08
To: users@cxf.apache.org
Subject: RE: getting the ip address in the action method

Thanks David,
Let me start by saying I consider myself to be a Java specialist, after
programming in it for years and teaching courses about it. So I was
amazed
to find out about this class "ThreadLocal" which is in core Java, and I
(and
my colleagues here in the office) haven't heard about it, ever. I love
to
learn something new always and this was really surprising... so, thanks
about that.

Back to our subject, this is a good solution for me, but I wonder, is
that
the elegant solution? Isn't there a way using CXF to do something like
that?

Thanks
Yair



-----Original Message-----
From: David Soroko [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 16, 2008 3:42 PM
To: users@cxf.apache.org
Subject: RE: getting the ip address in the action method

How about a thread local?

-----Original Message-----
From: Yair Ben-Meir [mailto:[EMAIL PROTECTED] 
Sent: 16 July 2008 13:36
To: users@cxf.apache.org
Subject: getting the ip address in the action method

Hi

I have a class implementing an interface annotated as a web service. In
the
method of this class, I handle the request.

Now, I want to use the IP of the client in the logic of the method. So I
wrote an interceptor that gets the IP:

public class IpCxfInterceptor extends AbstractPhaseInterceptor<Message>

{

      @Override

      public void handleMessage(Message message) throws Fault

      {

            HttpServletRequest request =

 

            (HttpServletRequest)
message.get(AbstractHTTPDestination.HTTP_REQUEST);

            String clientAddress = null;

            if (null != request)

            {

                  clientAddress = request.getRemoteAddr();

            }

            System.out.println("IP="

                + clientAddress);

      }

      

      public IpCxfInterceptor()

      {

            super(Phase.RECIEVE);

      }

}

 

The problem is - how can I pass the IP to the method? The method's
arguments
are according to the WSDL, I can't change them and add "ip" or something
like that.

 

Thanks

Yair

 

 


________________________________________________________________________
In order to protect our email recipients, Betfair Group use SkyScan from

MessageLabs to scan all Incoming and Outgoing mail for viruses.

________________________________________________________________________


________________________________________________________________________
In order to protect our email recipients, Betfair Group use SkyScan from 
MessageLabs to scan all Incoming and Outgoing mail for viruses.

________________________________________________________________________

Reply via email to