I guess you mean you need access to the ip address in the implementation
of the method. If you are using JAX-WS frontend you can add a custom
header in the message and inject webServiceContext into your service
implementation. once you are inside your method implementation you can
retrive your custom header from the webServiceContext which has the IP
address.
Here is a like to how to add out-of-band headers.
http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%252Fresponse%253F
Look at "How can I add soap headers to the request/response?" section
point 4.
-- Ulhas
Yair Ben-Meir wrote:
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
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland