Listing 10: SOAPServer.cpp.
#include "SOAPServer.h"
#include <iostream.h>
#include <waspc/common.h>
#include <waspc/runtime/Runtime.h>
#include <waspc/runtime/SuperFactory.h>
#include "DateTimeService.h"
WASP_FACTORY_DEFINE (DateTimeService);
using std::cout;
using std::endl;
int startSOAPServer() {
WASP_FactoryDefinition serviceFactory[] = {
WASP_FACTORY_ENTRY (DateTimeService), WASP_FACTORY_END ()
};
WASP_Runtime::initialize();
WASP_SuperFactory::registerFactory (serviceFactory);
cout << "Starting WASP Server on port 6070" << endl;
try {
WASP_Runtime::load("config.xml", NULL);
WASP_Runtime::start(NULL);
return 0;
} catch (WASP_Exception *exc) {
char *trace=GET_TRACE (exc);
cout << "Exception during startup: " << exc->getCharMessage()
<< endl;
cout << "Stack trace follows: " << endl << trace << endl;
delete[] trace;
delete exc;
return -1;
}
}
void stopSOAPServer() {
// Stop listening and kill services
WASP_Runtime::shutdown();
// Wait for all running services to complete
WASP_Runtime::waitForShutdown();
// release threads
WASP_Runtime::stop();
// release server resources
WASP_Runtime::destroy();
WASP_Runtime::terminate();
cout << "\nSOAP Server shutdown\n";
}