[ 
https://issues.apache.org/jira/browse/AXIS2-2176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sudhakar reddi updated AXIS2-2176:
----------------------------------

    Attachment: TestSessionService.aar

You can directly deploy this service and can test with client program and with 
browser.

> TransportSession among the beans is not working RPC client and working in 
> Browsers
> ----------------------------------------------------------------------------------
>
>                 Key: AXIS2-2176
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2176
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Test
>          Components: client-api
>    Affects Versions: 1.1.1
>         Environment: Tomcat 5.5 , Java 1.5 and axis2 Nightly build from 
> 14.02.2007 operating Windos XP Professional
>            Reporter: Sudhakar reddi
>            Priority: Minor
>             Fix For: nightly
>
>         Attachments: TestSessionService.aar
>
>
> Hi,
> I created two services and in scope "transportsession" in a same service 
> group. One Service I am trying to set the values in a SessionConext and 
> trying to retrive from the other service. This working fine with Broweres.
> My Test Approach:
> I took the Nightly build from 14.02.2007 deployed axis2.war and  
> TestSessionService.aar (which I developed ). In the First Service 
> TestLoginService I have a method called login where I am setting a value.
> and in the second service I have a method called getUser where I am trying to 
> retrieve a value. 
> if I test in browser as below
> http://localhost:8080/axis2/services/TestLoginService/login
> http://localhost:8080/axis2/services/TestService/getUser
> it is working fine. but in RPC Client it is not working. The session  is 
> maintaining  within the  bean is working fine in RPCclient. i.e If I am 
> setting a value in one service call and If I trying to retrieve tha value in 
> another call, it is working fine. For testing that I am a having a setUser 
> and getUser in the TestService.
> My service.xml
> ---------------------------------------------------------------------------------------------------------------------------------------------
> <serviceGroup>
> <service name="TestLoginService" scope="transportsession">
>     <description>
>         Service For Logging and maintaing the session
>     </description>
>     <messageReceivers>
>         <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only";
>                          
> class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
>         <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out";
>                          
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>     </messageReceivers>
>     <parameter name="ServiceClass" 
> >com.test.service.TestLoginService</parameter>
> </service>
> <service name="TestService" scope="transportsession">
>     <description>
>         Service For Logging and maintaing the session
>     </description>
>     <messageReceivers>
>         <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only";
>                          
> class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
>         <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out";
>                          
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>     </messageReceivers>
>     <parameter name="ServiceClass" >com.test.service.TestService</parameter>
> </service>
> </serviceGroup>
> ---------------------------------------------------------------------------------------------------------------------------------------
> TestLoginService.java
> package com.test.service;
> import  org.apache.axis2.context.ServiceContext;
> import  org.apache.axis2.context.MessageContext;
> import  org.apache.axis2.context.SessionContext;
> public class TestLoginService
> {
>     public void init(ServiceContext serviceContext) {
>         System.out.println("init method invoked");
>     }
>     public void destroy(ServiceContext serviceContext) {
>         System.out.println("destroy method invoked");
>     }
>     public void login()
>     {
>         getSessionContext().setProperty("USER_ID", "Sudhaka");
>         System.out.println("User Login Method 
> :"+getSessionContext().getCookieID());
>         //return true;
>     }
>     private SessionContext getSessionContext() {
>        MessageContext messageContext = 
> MessageContext.getCurrentMessageContext();
>        SessionContext sessionContext = messageContext.getSessionContext();
>        return sessionContext;
>     }
> }
> ---------------------------------------------------------------------------------------------------------------------
> TestService.java
> package com.test.service;
> import  org.apache.axis2.context.ServiceContext;
> import  org.apache.axis2.context.MessageContext;
> import  org.apache.axis2.context.SessionContext;
> public class TestService
> {
>       private static String PROP_COUNTER = "property.counter";
>     public void destroy(ServiceContext serviceContext) {
>         System.out.println("TestService destroy method invoked");
>     }
>     public String getUser()
>     {
>         System.out.println("getUser Login 
> Cookie:"+getSessionContext().getCookieID());
>         String userid = (String)getSessionContext().getProperty("USER_ID");
>         System.out.println("UserId"+userid);
>         return userid;
>     }
>     public int plusone() {
>                       printMessage("plusone()", "begin");
>                       SessionContext sessionContext = getSessionContext();
>                       int counter = 1 + 
> Integer.parseInt((String)sessionContext.getProperty(PROP_COUNTER).toString());
>                       sessionContext.setProperty(PROP_COUNTER, new 
> Integer(counter));
>                       printMessage("plusone()", 
> "sessionId="+sessionContext.getCookieID()+", counter="+counter);
>                       return counter;
>       }
>     private SessionContext getSessionContext() {
>        MessageContext messageContext = 
> MessageContext.getCurrentMessageContext();
>        SessionContext sessionContext = messageContext.getSessionContext();
>        return sessionContext;
>     }
>     private void printMessage(String method, String message) {
>                       System.out.println(method+"::"+message);
>       }
> public void init(ServiceContext serviceContext) {
>               printMessage("init()", "begin");
>               SessionContext sessionContext = getSessionContext();
>               sessionContext.setProperty(PROP_COUNTER, new Integer(1));
>               printMessage("init()", 
> "sessionContext="+sessionContext.getCookieID()+", reset counter to 1 in 
> session");
>       }
>       public void setUser(String user )
>       {
>               System.out.println("Set method:"+user);
>               getSessionContext().setProperty("USER_ID", "Test123");
>         System.out.println("Login Cookie:"+getSessionContext().getCookieID());
>       }
> }
> ----------------------------------------------------------------------------------------------------------------
> TestRpcClient.java
> RPCServiceClient serviceClient = new RPCServiceClient();
>         Options options = serviceClient.getOptions();
>         EndpointReference targetEPRLogin = new 
> EndpointReference("http://127.0.0.1:8080/axis2/services/TestLoginService";);
>         options.setTo(targetEPRLogin);
>         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>         options.setManageSession(true);
>               options.setAction("urn:login");
>               serviceClient.setOptions(options);
>         QName opAddEntry = new QName("http://service.test.com/xsd";, "login");
>         Object[] opAddEntryArgs = new Object[] {  };
>         serviceClient.invokeRobust(opAddEntry, opAddEntryArgs);
>               //Calling the session Value in Anothe Bean
>               EndpointReference targetEPRTest = new 
> EndpointReference("http://127.0.0.1:8080/axis2/services/TestService";);
>               options = serviceClient.getOptions();
>                options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>         options.setManageSession(true);
>       options.setTo(targetEPRTest);
>       options.setAction("urn:getUser");
>         QName opFindEntry = new QName("http://service.test.com/xsd";, 
> "getUser");
>         Object[] opFindEntryArgs = new Object[] {  };
>         Class[] returnTypes = new Class[] { String.class };
>         Object[] response = serviceClient.invokeBlocking(opFindEntry,
>                 opFindEntryArgs, returnTypes);
>         String result = (String) response[0];
>         System.out.println("Bug result " + result);
>               //Setting User in the same Bean as a session value
>         options.setAction("urn:setUser");
>         options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>         options.setManageSession(true);
>         opFindEntry = new QName("http://service.test.com/xsd";, "setUser");
>         opFindEntryArgs = new Object[] { "Test" };
>               serviceClient.invokeRobust(opAddEntry, opFindEntryArgs);
>               //Getting the value from the session
>               options.setAction("urn:getUser");
>               options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
>         options.setManageSession(true);
>               opFindEntry = new QName("http://service.test.com/xsd";, 
> "getUser");
>               opFindEntryArgs = new Object[] {  };
>               returnTypes = new Class[] { String.class };
>         response = serviceClient.invokeBlocking(opFindEntry, opFindEntryArgs, 
> returnTypes);
>         result = (String) response[0];
>               System.out.println("Session Value Result:"+result);
> ------------------------------------------------------------------------------------------------------
> Please let me know if I am doing something wrong here. The similar bug 
> Axis2-2042 is working fine because it is within the bean.
> Regards
> Sudhakar

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to