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)
;
Am I missing something important here? Anyone know why the
session is not applied across all servicegroups?
Thanks
Jamie