Thanks !!!,
I analize your example code and my import package is wrong!
My wrong import:
import org.apache.axis.MessageContext;
Your import:
import org.apache.axis2.context.MessageContext;
I change this and sucessfully retrive of MessageContext and client IP
address.
This is the my code for other user's with the same problem:
import org.apache.axis2.context.MessageContext;
....
public String authenticate(String ip){
...
MessageContext messageContext =
MessageContext.getCurrentMessageContext();
if(messageContext != null){
ipAddress = (String)messageContext.getProperty("REMOTE_ADDR");
}
logger.debug(ipAddress);
...
return "OK";
}
Thanks again ;)
Deepal Jayasinghe wrote:
Nope it can not be, have a look at the attached service it worked fine
for me and I got the expected output too.
Note: You need to rename sample.zip file into sample.aar before
deploying the service
Once you deploy, you can invoke the service by typing following in the
browser.
http://localhost:8080/axis2/services/SessionService/getCurret?value=10
Edgardo Ibañez O. wrote:
Thanks for your answer.
I tried implements like http://wso2.org/library/480, but in this
example, they obtain the information from a msgCtx variable, and my
problem is obtain a MessageContext != null, in this article not obtain
the MessageContext, only they use this. In the other article they
obtain the messageContext of the same way than me: MessageContext
messageContext =MessageContext.getCurrentContext(). but I retrieve a
null value.
Thanks for read.
Deepal Jayasinghe wrote:
Well you do not need to do anything in the axis2.xml to access the
MessageContext.
Have a look at
http://wso2.org/library/480
http://wso2.org/library/articles/axis2-session-management
Thank you!
Deepal
Edgardo Ibañez O. wrote:
Hi all, this is my first post at this mailing list, my problem is
covered in other post, but I dont have the real solution.
I tried to access de MessageContext from the implementation class like
this:
ipAddress = messageContext.getStrProp(Constants.MC_REMOTE_ADDR);
but messageContext is null, I read too much documentation, and I dont
encountered the reason for the null value,
I tried to place the axis.jar in distinct classloader and the same
classloader than the service implementation class and this not run :(
Exist any form to obtain the client ip address from the service class
implementation?
I need any "special" configuration in axis2.xml to access the
MessageContext from the implementation class?
If I retrieve the ip address from a handler, How I pass this to the
implementation service class?
I never implement a handler and this scarry me :(
My service is a POJO implemetation
Thanks for read my question.
Greeetings.
PD: Sorry for my bad english.