Hi,
I'm trying to build an axis2 web services into an existing application
framework. This current framework creates a number of resources (mainly
references to internal handlers for things like logging and other common
capabilities of the system) which need to be passed to the business logic so
that when SOAP messages are received the business logic can extract
information from the messages and pass the extracted data to these handlers.
The current application framework is a standalone app and isn't running within
a servlet container. It's also not built using Spring, and retrofitting it to
work with Spring is not really an option.
The webservice I need to implement is supported by a wsdl which I have
successfully compiled into the appropriate classes and the MessageReceiver
and skeleton classes. My problem is I don't know how to initialise these with
the application's resources so that they get references to them
Currently I'm initialising Axis2 as follows:
ConfigurationContext confCon =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("./repository","./conf/axis2.xml");
Obviously this starts up the axis2 server and deploys the services. I can
modify the wdsl2java generated MessageReceiver class to add a constructor
with a print statement, and the output appears in the logs. I can add print
statements to the skeleton class and these show up when I push a message into
the application. All working nicely.
My problem is, how do I get references to the resources in my main program to
the skeleton class?
I have found I can pass some parameters by piggy-backing on the Configuration
Context, thus -
Main program:
ConfigurationContext confCon =
ConfigurationContextFactory.createConfigurationContextFromFileSystem("./repository","./conf/axis2.xml");
Logger logger = new Logger(config); // Example of a generic Logger resource
// Some trickery to pass logger reference into Message Receiver or skeleton
class
confCon.setProperty("TestParm", "test2");
MessageReceiver:
public void invokeBusinessLogic(org.apache.axis2.context.MessageContext
inMessage) throws org.apache.axis2.AxisFault{
try {
// get the implementation class for the Web Service
Object obj = getTheImplementationObject(inMessage);
String testParm = (String)
inMessage.getConfigurationContext().getProperty("TestParm");
System.out.println("############################# Found TestParm
="+testParm);
...
Firstly is this a reasonable approach? Secondly is there any way I can do this
just once, rather than for each message. Ideally I would like to do this in
the Message Receiver constructor, but I can't find any way of getting any
useful context information at this point.
Cheers,
--
Keith A. Milner