留言板

Web services client + check if user exists?

Rick Dangerous,修改在12 年前。

Web services client + check if user exists?

Junior Member 帖子: 61 加入日期: 11-1-25 最近的帖子
HI
I'm learning to handle web services, and I making a web service client that access to liferay's web services.
I want to check if user existe by mail.
I have this code:
UserSoap user = null;

try {
    user = userServiceSoap.getUserByEmailAddress(companyId, "mail@mail.com");
} catch (RemoteException ex) {
    //Not exist?
}


At this way, if user not exist , user = null. OK at this point.

Mi question is about the exception... RemoteException it's a generic exception that I can't filter. If there is another kind of error, that not existe user, catch will be throw too?

At debug, I try to watch Exception "cause" and "detail" properties ....but there are null, and all exceptions that throws web services calls = RemoteException. I can't check if there is another kind of Exception to filter, and check that the Exception is because the user not exist (ant then I add user).

What will be the best practice to resolve?

Thanks and sorry for my poor english