Hi, sorry for the
big message... but I've got a fairly big problem! :}
I created some web
services with an older version of AXIS using JBuilder6 (with the web services
for java addon - using the "Export as WebService" wizard), and had some success
in getting multiple services talking to the same session using wsdl2java
generated classes (Automatically generated by the wizard)... The following
code (just a snippet from a test class...), is using these classes...
:-
String Cookie = "JSESSIONID=" + getSessionID();
//Create validation service
ValidationService vs = new ValidationServiceLocator();
Validation v2 = vs.getValidation();
((org.apache.axis.client.Stub)v2).setMaintainSession(true);
((org.apache.axis.client.Stub)v2)._setProperty("Cookie",
Cookie);
//Validate login details
int UserID = v2.ValidateLogin(strUser, strPass);
if (UserID != -1) {
//Create search service
SearchFunctionsService ss = new SearchFunctionsServiceLocator();
SearchFunctions s2 = ss.getSearchFunctions();
((org.apache.axis.client.Stub)s2).setMaintainSession(true);
((org.apache.axis.client.Stub)s2)._setProperty("Cookie", Cookie);
SearchInfo[] searches = s2.ListSearches(UserID);
//Validate login details
int UserID = v2.ValidateLogin(strUser, strPass);
if (UserID != -1) {
//Create search service
SearchFunctionsService ss = new SearchFunctionsServiceLocator();
SearchFunctions s2 = ss.getSearchFunctions();
((org.apache.axis.client.Stub)s2).setMaintainSession(true);
((org.apache.axis.client.Stub)s2)._setProperty("Cookie", Cookie);
SearchInfo[] searches = s2.ListSearches(UserID);
// ... [Code removed for
brevity]
}
} catch (Exception ex) {
ex.printStackTrace();
}
The webSevices
have the following code in their instantiation routines
:-
public Validation() {
try {
if (MessageContext.getCurrentContext() != null) {
mySession = MessageContext.getCurrentContext().getSession();
try {
if (MessageContext.getCurrentContext() != null) {
mySession = MessageContext.getCurrentContext().getSession();
if (mySession == null)
{
throw new InvalidSessionException();
}
} else {
throw new InvalidSessionException();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
throw new InvalidSessionException();
}
} else {
throw new InvalidSessionException();
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
And in most of the
function calls the following code is used to determine if a user has logged in
or not... :-
public SearchInfo[] ListSearches(int UserID) throws Exception
{
if (mySession.get("LoggedIn").equals("1"))
{
//Get the searches for the
given user
// ... [Code is here... removed for brevity]
}
else {
throw new NotLoggedInException();
}
// ... [Code is here... removed for brevity]
}
else {
throw new NotLoggedInException();
}
}
This code was
working great until I moved to JBuilder8, and it's new version of AXIS...
Now it seems to be ignoring the cookie that I am setting, and using it's own
(different for each service) cookies :/
Is there a
"new" way of setting cookies?
I am using
"session" level scope on my web services (defined in the deploy.wsdd
file).
I hope
somebody can help.. cos at this rate, i'm going to have to downgrade back to
JBuilder6 and it's older version of AXIS to get this to work... (Something I
don't really want to do...)
tia.
/James.
