/* * testHttpCodec.cpp * * Created on: 2017年1月12日 * Author: liu */ #include #include "HttpCodec.h" #include "XmlBuilder.h" #include "SoapUtils.h" using namespace std; using namespace onvif; #define TEST_REQ \ "Host: 192.168.205.12\r\n" \ "User-Agent: Dahua SOAP Client\r\n" \ "Content-Type: application/soap+xml; charset=utf-8\r\n" \ "Content-Length: 1470\r\n" \ "Connection: close\r\n" \ "\r\n" \ "
2016-12-30T10:38:09Z2016-12-30T10:38:09ZadminoEpIoYwhTL3sm6cTHEIgwdZsuj8=tM4dP10OYGykPGoa+lp4CCsSgDY=2016-12-30T10:38:09Z
All
" #define TEST_SOAP_REQ_STR \ "POST /onvif/device_service HTTP/1.1\r\n" \ "Host: 192.168.205.12\r\n" \ "User-Agent: Dahua SOAP Client\r\n" \ "Content-Type: application/soap+xml; charset=utf-8\r\n" \ "Content-Length: 963\r\n" \ "Connection: close\r\n" \ "\r\n" \ "" \ "All\r\n" int main(int argc, char **argv) { HttpCodec decode; HttpRequest req; int ret = decode.parse(TEST_SOAP_REQ_STR, req); if (ret == -1) { LOG("parsing request failed!"); return -1; } // req.dump(); XmlBuilder builder; ret = builder.parse(req.content.c_str()); if (ret == -1) { cout << "xml parsing failed!" << endl; return -1; } if (builder.noDefaultNamespace()) { builder.setPathNamespace("xmlns", SoapUtils::getAllXmlNameSpace()["xmlns"]); } builder.dump(); cout << endl; cout << "function name: " << SoapUtils::soapFunctionName(builder) << endl; /** * only for test soaputils */ cout << endl; XmlBuilder test1("Envelope"); SoapUtils::addVisitNamespace(test1, "wsnt:tdn:trt", SoapUtils::getAllXmlNameSpace()); test1["Envelope.Body.Test"]; test1.dump(); return 0; }