Hi,

AFAIK setManageSession works within the scope of a stub. That is you can 
invoke several operations in a service within a single session. Here the 
case is different. Tho services are different and Axis2 is not 
preserving the session cookie for you.

The workaround would be this.

1' Invoke the login method.
2. get the cookie from the response
3. Set the cookie manually during subsequent invocations of ServerAdmin

:).

Thanks,
Keith.

Hiranya Jayathilaka wrote:
> Hi Folks,
>
> We are trying to develop a client for the WSAS admin services (WSAS 
> version is 2.3). We want to invoke the restart operation of the 
> ServerAdmin service using a client. So we used WSDL2Code to generate 
> the necessary stubs for the GlobalAdmin and ServerAdmin services. Then 
> using the GlobalAdmin client we are able to login to WSAS. Now we want 
> to restart the server using the established session. How can we do 
> this in our code. We tried the following but it didn't work.
>
>         String path = System.getProperty("user.dir");
>         System.setProperty("javax.net.ssl.trustStore", path + 
> "/src/wso2wsas.jks");
>         System.getProperty("javax.net.ssl.trustStorePassword", 
> "wso2wsas");
>         GlobalAdminStub gStub = new GlobalAdminStub();
>         Options options = gStub._getServiceClient().getOptions();
>         options.setManageSession(true);
>         Login login = new Login();
>         login.setUsername("admin");
>         login.setPassword("admin");
>        
>         if (gStub.login(login).get_return()) {
>             ServerAdminStub stub = new ServerAdminStub(cfgCtx);
>             stub._getServiceClient().getOptions().setManageSession(true);
>             stub.restart();
>         }
>
> This code returns the following exception.
>
> Exception in thread "main" org.apache.axis2.AxisFault: Access Denied. 
> Please login first.
>     at 
> org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
>     at 
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
>     at 
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
>     at 
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
>     at 
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
>     at 
> org.wso2.wsas.admin.service.ServerAdminStub.restart(ServerAdminStub.java:193)
>     at org.moinc.server.test.WSASHandler.main(WSASHandler.java:29)
>
> According to the WSAS logs the login attempt has been successful. But 
> the restart operation has failed. Can somebody please help me figure 
> out the correct way to do this?
>
> Thanks
>
> Best Regards,
> Hiranya
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Wsas-java-dev mailing list
> [email protected]
> https://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev
>   


_______________________________________________
Wsas-java-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev

Reply via email to