You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
![]()
7 years ago
|
#include "webcc/soap_request.h"
|
||
![]()
7 years ago
|
|
||
![]()
7 years ago
|
#include "webcc/soap_xml.h"
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
namespace webcc {
|
||
![]()
8 years ago
|
|
||
|
void SoapRequest::AddParameter(const Parameter& parameter) {
|
||
|
parameters_.push_back(parameter);
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
void SoapRequest::AddParameter(Parameter&& parameter) {
|
||
|
parameters_.push_back(std::move(parameter));
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
const std::string& SoapRequest::GetParameter(const std::string& key) const {
|
||
![]()
8 years ago
|
for (const Parameter& p : parameters_) {
|
||
|
if (p.key() == key) {
|
||
|
return p.value();
|
||
|
}
|
||
|
}
|
||
![]()
8 years ago
|
|
||
|
static const std::string kEmptyValue;
|
||
|
return kEmptyValue;
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
void SoapRequest::ToXmlBody(pugi::xml_node xbody) {
|
||
![]()
7 years ago
|
pugi::xml_node xop = soap_xml::AddChild(xbody, service_ns_.name, operation_);
|
||
![]()
7 years ago
|
soap_xml::AddNSAttr(xop, service_ns_.name, service_ns_.url);
|
||
![]()
8 years ago
|
|
||
|
for (Parameter& p : parameters_) {
|
||
![]()
7 years ago
|
pugi::xml_node xparam = soap_xml::AddChild(xop, service_ns_.name, p.key());
|
||
![]()
8 years ago
|
xparam.text().set(p.value().c_str());
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
}
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
bool SoapRequest::FromXmlBody(pugi::xml_node xbody) {
|
||
|
pugi::xml_node xoperation = xbody.first_child();
|
||
|
if (!xoperation) {
|
||
|
return false;
|
||
|
}
|
||
![]()
8 years ago
|
|
||
![]()
7 years ago
|
soap_xml::SplitName(xoperation, &service_ns_.name, &operation_);
|
||
|
service_ns_.url = soap_xml::GetNSAttr(xoperation, service_ns_.name);
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
pugi::xml_node xparameter = xoperation.first_child();
|
||
|
while (xparameter) {
|
||
|
parameters_.push_back({
|
||
![]()
7 years ago
|
soap_xml::GetNameNoPrefix(xparameter),
|
||
![]()
8 years ago
|
std::string(xparameter.text().as_string())
|
||
|
});
|
||
![]()
8 years ago
|
|
||
![]()
8 years ago
|
xparameter = xparameter.next_sibling();
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
8 years ago
|
return true;
|
||
![]()
8 years ago
|
}
|
||
|
|
||
![]()
7 years ago
|
} // namespace webcc
|