1 #include "otsdaq/SOAPUtilities/SOAPMessenger.h"
2 #include "otsdaq/Macros/CoutMacros.h"
3 #include "otsdaq/MessageFacility/MessageFacility.h"
4 #include "otsdaq/SOAPUtilities/SOAPCommand.h"
5 #include "otsdaq/SOAPUtilities/SOAPUtilities.h"
7 #include <xdaq/NamespaceURI.h>
8 #include <xoap/MessageReference.h>
9 #include <xoap/Method.h>
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
12 #include <xoap/MessageFactory.h>
13 #pragma GCC diagnostic pop
14 #include <xoap/AttachmentPart.h>
15 #include <xoap/SOAPBody.h>
16 #include <xoap/SOAPEnvelope.h>
17 #include <xoap/SOAPPart.h>
18 #include <xoap/domutils.h>
23 SOAPMessenger::SOAPMessenger(xdaq::Application* application)
24 : theApplication_(application)
29 SOAPMessenger::SOAPMessenger(
const SOAPMessenger& aSOAPMessenger)
30 : theApplication_(aSOAPMessenger.theApplication_)
39 std::string SOAPMessenger::send(XDAQ_CONST_CALL xdaq::ApplicationDescriptor* ind,
40 xoap::MessageReference message)
43 return SOAPUtilities::receive(sendWithSOAPReply(ind, message));
51 if(soapCommand.hasParameters())
52 return send(d, soapCommand.
getCommand(), soapCommand.getParameters());
62 xoap::MessageReference message = SOAPUtilities::makeSOAPMessageReference(command);
66 msgStr =
send(d, message);
70 __COUT__ <<
"send failed?!" << __E__;
71 __COUT__ << SOAPUtilities::translate(message) << __E__;
84 return SOAPUtilities::receive(sendWithSOAPReply(ind, cmd, parameters));
88 xoap::MessageReference SOAPMessenger::sendWithSOAPReply(
89 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* ind, std::string cmd)
92 return sendWithSOAPReply(ind, SOAPUtilities::makeSOAPMessageReference(cmd));
96 xoap::MessageReference SOAPMessenger::sendWithSOAPReply(
97 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* ind, xoap::MessageReference message)
103 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* d =
104 const_cast<xdaq::ApplicationDescriptor*
>(ind);
107 message->getMimeHeaders()->setHeader(
"Content-Location", d->getURN());
108 message->getMimeHeaders()->setHeader(
"xdaq-pthttp-connection-timeout",
117 xoap::MessageReference reply = theApplication_->getApplicationContext()->postSOAP(
118 message, *(theApplication_->getApplicationDescriptor()), *d);
121 catch(xdaq::exception::Exception& e)
128 XCEPT_RETHROW(xdaq::exception::Exception,
"Failed to send SOAP command.", e);
133 xoap::MessageReference SOAPMessenger::sendWithSOAPReply(
134 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* ind,
139 return sendWithSOAPReply(ind,
140 SOAPUtilities::makeSOAPMessageReference(cmd, parameters));
144 std::string SOAPMessenger::sendStatus(XDAQ_CONST_CALL xdaq::ApplicationDescriptor* ind,
151 XDAQ_CONST_CALL xdaq::ApplicationDescriptor* d =
152 const_cast<xdaq::ApplicationDescriptor*
>(ind);
154 std::string cmd =
"StatusNotification";
158 gettimeofday(&tv, NULL);
160 std::stringstream ss;
162 parameters.addParameter(
"Description", message);
165 parameters.addParameter(
"Time", ss.str());
168 parameters.addParameter(
"usec", ss.str());
169 return send(d, cmd, parameters);
171 catch(xdaq::exception::Exception& e)
173 __COUT__ <<
"This application failed to send a SOAP error message to "
174 << d->getClassName() <<
" instance " << d->getInstance()
175 <<
" with command = " << cmd
176 <<
" re-throwing exception = " << xcept::stdformat_exception_history(e)
178 XCEPT_RETHROW(xdaq::exception::Exception,
"Failed to send SOAP command.", e);
const std::string & getCommand(void) const
Getters.
std::string send(XDAQ_CONST_CALL xdaq::ApplicationDescriptor *d, xoap::MessageReference message)