CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SoapUtils.cc
Go to the documentation of this file.
1 
10 
11 #include "xdaq/NamespaceURI.h"
12 #include "xoap/MessageFactory.h"
13 #include "xoap/Method.h"
14 #include "xoap/SOAPBody.h"
15 #include "xoap/SOAPEnvelope.h"
16 #include "xoap/SOAPName.h"
17 #include "xoap/SOAPPart.h"
18 #include "xoap/domutils.h"
19 
20 #include "xdaq2rc/version.h"
21 #include "xdaq2rc/SOAPParameterExtractor.hh"
22 
23 using std::string;
24 
25 namespace evf {
26 namespace soaputils {
27 
28 string extractParameters(xoap::MessageReference msg, xdaq::Application* app) {
29  string command;
30 
31  // Extract the command name and update any configuration parameter
32  // found in the SOAP message in the application infospace
33  xdaq2rc::SOAPParameterExtractor soapParameterExtractor(app);
34  command = soapParameterExtractor.extractParameters(msg);
35  return command;
36 }
37 
38 xoap::MessageReference createFsmSoapResponseMsg(const string commandName,
39  const string currentState) {
40  xoap::MessageReference reply;
41 
42  try {
43  // response string
44  reply = xoap::createMessage();
45  xoap::SOAPEnvelope envelope = reply->getSOAPPart().getEnvelope();
46  xoap::SOAPName responseName = envelope.createName(
47  commandName + "Response", "xdaq", XDAQ_NS_URI);
48  xoap::SOAPBodyElement responseElem = envelope.getBody().addBodyElement(
49  responseName);
50 
51  // state string
52  xoap::SOAPName stateName = envelope.createName("state", "xdaq",
53  XDAQ_NS_URI);
54  xoap::SOAPElement stateElem = responseElem.addChildElement(stateName);
55  xoap::SOAPName attributeName = envelope.createName("stateName", "xdaq",
56  XDAQ_NS_URI);
57  stateElem.addAttribute(attributeName, currentState);
58  } catch (xcept::Exception &e) {
59  XCEPT_RETHROW(
61  "Failed to create FSM SOAP response message for command '"
62  + commandName + "' and current state '" + currentState
63  + "'.", e);
64  }
65 
66  return reply;
67 }
68 
69 } // namespace soaputils
70 
71 } // namespace evf
std::string extractParameters(xoap::MessageReference, xdaq::Application *)
Definition: SoapUtils.cc:28
xoap::MessageReference createFsmSoapResponseMsg(const std::string commandName, const std::string currentState)
Definition: SoapUtils.cc:38