On Fri, Feb 26, 2010 at 5:46 PM, jamie <[email protected]> wrote: > Hi Everyone > > Thanks for your suggestions regarding multiple classes. I've decided to use > multiple web services for each section of the API, however, I cannot get > services within the servicegroup to > share properties. > > In the Test web service that controls the login. Once the user has logged > in successfully, I call the newSession object that sets the > Config object to a property. > > private void newSession() throws AxisFault { > if(mc!=null) { > ServiceGroupContext sgc = mc.getServiceGroupContext(); > if (sgc != null) { > sgc.setProperty("config", config); > } > } > } > > In the services.xml, I set the scope of each of the services to > "transportsession": > > <service name="Test2" scope="transportsession"> > <Description> > MailArchiva search API > </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" > locked="false">com.test.Test2</parameter> > </service> > > <service name="Test1" scope="transportsession"> > <Description> > Test API > </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" > locked="false">com.test.Test1</parameter> > </service> > > In the Test2 service implementation, I have a getConfig() object which is > called by each of the methods to set the internal application configuration > object > > > private Config getConfig() throws AxisFault { > MessageContext mc = MessageContext.getCurrentMessageContext(); > if(mc.getServiceGroupContext()!=null) { > Config config = > (Config)mc.getServiceGroupContext().getProperty("config"); > if (config!=null) { > return config; > } > } > throw new AxisFault("not logged in"); > } > > > When the web service client calls the above, getProperty("config") always > returns null. Thus, > there is no sharing taking place. > > In the web service client, I do the following: > > test1Stub = new Test1Stub(url+"/MailArchiva"); > test1Stub._getServiceClient().getOptions().setManageSession(true); >
do you invoke Test2 using test2Stub? in that case the cookie information may not send with the second request. you can confirm this by sending messages from a tcpmon[1]. if it is the case try this[2] you need to manually copy the cookie details as given there. this[3] may also help you to understand how Axis2 handle scopes. Regarding using multiple classes you have no option other than publishing every class as a separate service. thanks, Amila. [1] http://ws.apache.org/commons/tcpmon/ [2] http://amilachinthaka.blogspot.com/2009/02/accessing-wso2-products-back-end.html [3] https://www.wso2.org/library/articles/stateful-web-services-axis2 > > Am I missing something important here? Anyone know why the session is not > applied across all servicegroups? > > Thanks > > Jamie > > -- Amila Suriarachchi WSO2 Inc. blog: http://amilachinthaka.blogspot.com/
