diff --git a/esp/bindings/SOAP/Platform/soapbind.hpp b/esp/bindings/SOAP/Platform/soapbind.hpp index a2085e392bd..8537f8232fc 100644 --- a/esp/bindings/SOAP/Platform/soapbind.hpp +++ b/esp/bindings/SOAP/Platform/soapbind.hpp @@ -36,6 +36,7 @@ #include "espbinding.hpp" #include "http/platform/httpbinding.hpp" +#include class esp_http_decl CSoapComplexType : implements IRpcSerializable, public CInterface { diff --git a/esp/bindings/SOAP/Platform/soaphidlbind.cpp b/esp/bindings/SOAP/Platform/soaphidlbind.cpp new file mode 100644 index 00000000000..5238b9bf292 --- /dev/null +++ b/esp/bindings/SOAP/Platform/soaphidlbind.cpp @@ -0,0 +1,50 @@ +/*############################################################################## + + HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +############################################################################## */ + +#pragma warning( disable : 4786 ) + +#include "soaphidlbind.hpp" + +void CHttpSoapHidlBinding::registerMethodNames(std::initializer_list names) +{ + for (const char *name : names) + { + std::string methodNameKey(name); + std::transform(methodNameKey.cbegin(), methodNameKey.cend(), methodNameKey.begin(), tolower); + m_qualifiedMethodNames.emplace(methodNameKey.c_str(), name); + } +} + +bool CHttpSoapHidlBinding::qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName) +{ + if (!methname || !*methname) + { + if (methQName != nullptr) + methQName->clear(); + return true; + } + std::string methodName(methname); + std::transform(methodName.cbegin(), methodName.cend(), methodName.begin(), tolower); + auto it = m_qualifiedMethodNames.find(methodName); + if (it != m_qualifiedMethodNames.end()) + { + if (methQName != nullptr) + methQName->set(it->second.c_str()); + return true; + } + return false; +} \ No newline at end of file diff --git a/esp/bindings/SOAP/Platform/soaphidlbind.hpp b/esp/bindings/SOAP/Platform/soaphidlbind.hpp new file mode 100644 index 00000000000..ec0d037e8ad --- /dev/null +++ b/esp/bindings/SOAP/Platform/soaphidlbind.hpp @@ -0,0 +1,37 @@ +/*############################################################################## + + HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +############################################################################## */ + +#ifndef _SOAPHIDLBIND_HPP__ +#define _SOAPHIDLBIND_HPP__ + +#include "soapbind.hpp" + +class esp_http_decl CHttpSoapHidlBinding : public CHttpSoapBinding +{ +public: + CHttpSoapHidlBinding(IPropertyTree* cfg, const char *bindname=NULL, const char *procname=NULL, http_soap_log_level level=hsl_none) : + CHttpSoapBinding(cfg, bindname, procname, level) {} + virtual bool qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName); + +protected: + virtual void registerMethodNames(std::initializer_list names); + +private: + std::map m_qualifiedMethodNames; +}; + +#endif diff --git a/esp/protocols/http/CMakeLists.txt b/esp/protocols/http/CMakeLists.txt index db16c06339a..3a3f31a214c 100644 --- a/esp/protocols/http/CMakeLists.txt +++ b/esp/protocols/http/CMakeLists.txt @@ -37,6 +37,7 @@ set(SRCS ../../bindings/http/platform/msgbuilder.cpp ../../bindings/SOAP/client/soapclient.cpp ../../bindings/SOAP/Platform/soapbind.cpp + ../../bindings/SOAP/Platform/soaphidlbind.cpp ../../bindings/SOAP/Platform/soapmessage.cpp ../../bindings/SOAP/Platform/soapservice.cpp ../../bindings/SOAP/Platform/soapparam.cpp diff --git a/tools/hidl/hidlcomp.cpp b/tools/hidl/hidlcomp.cpp index 9963ac732d1..42b58d58c2d 100644 --- a/tools/hidl/hidlcomp.cpp +++ b/tools/hidl/hidlcomp.cpp @@ -3932,7 +3932,7 @@ void EspServInfo::write_esp_binding_ipp() { EspMethodInfo *mthi=NULL; - outf("\n\nclass C%sSoapBinding : public CHttpSoapBinding\n", name_); + outf("\n\nclass C%sSoapBinding : public CHttpSoapHidlBinding\n", name_); outs("{\npublic:\n"); //dom @@ -3960,9 +3960,6 @@ void EspServInfo::write_esp_binding_ipp() //method ==> isValidServiceName outs("\tbool isValidServiceName(IEspContext &context, const char *name);\n"); - //method ==> qualifyMethodName - outs("\tbool qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName);\n"); - //method ==> qualifyServiceName outs("\tbool qualifyServiceName(IEspContext &context, const char *servname, const char *methname, StringBuffer &servQName, StringBuffer *methQName);\n"); @@ -4084,13 +4081,13 @@ void EspServInfo::write_esp_binding(const char *packagename) StrBuffer servicefeatureurl; getMetaStringValue(servicefeatureurl,FEATEACCESSATTRIBUTE); - outf("\nC%sSoapBinding::C%sSoapBinding(http_soap_log_level level):CHttpSoapBinding(NULL, NULL, NULL, level)\n", name_, name_); + outf("\nC%sSoapBinding::C%sSoapBinding(http_soap_log_level level):CHttpSoapHidlBinding(NULL, NULL, NULL, level)\n", name_, name_); outf("{\n"); outf("\tinit_strings();\n"); outf("\tsetWsdlVersion(%s);\n", wsdlVer.str()); outf("}\n"); - outf("\nC%sSoapBinding::C%sSoapBinding(IPropertyTree* cfg, const char *bindname, const char *procname, http_soap_log_level level):CHttpSoapBinding(cfg, bindname, procname, level)\n", name_, name_); + outf("\nC%sSoapBinding::C%sSoapBinding(IPropertyTree* cfg, const char *bindname, const char *procname, http_soap_log_level level):CHttpSoapHidlBinding(cfg, bindname, procname, level)\n", name_, name_); outf("{\n"); outf("\tinit_strings();\n"); outf("\tinit_metrics();\n"); @@ -4168,13 +4165,23 @@ void EspServInfo::write_esp_binding(const char *packagename) // init_maps implementation outf("\nvoid C%sSoapBinding::init_maps()\n", name_); outs("{\n"); + outs("\tstd::initializer_list names = {\n"); for (mthi=methods; mthi!= nullptr; mthi=mthi->next) { - std::string methodNameKey(mthi->getName()); - std::transform(methodNameKey.cbegin(), methodNameKey.cend(), methodNameKey.begin(), tolower); - outf("\tm_qualifiedMethodNames.emplace(\"%s\", \"%s\");\n", methodNameKey.c_str(), mthi->getName()); + outf("\t\t\"%s\"", mthi->getName()); + if (mthi->next != nullptr) + { + outs(",\n"); + } + else + { + outs("\n"); + } } - outs("}\n"); + outs("\t};\n"); + + outs("\tregisterMethodNames(names);\n"); + outs("}"); outf("\nint C%sSoapBinding::processRequest(IRpcMessage* rpc_call, IRpcMessage* rpc_response)\n", name_); outs("{\n"); @@ -4379,31 +4386,6 @@ void EspServInfo::write_esp_binding(const char *packagename) outs(2, "return (hasSubService(context, name));\n"); outs("}\n"); - //method ==> qualifyMethodName - outf("\nbool C%sSoapBinding::qualifyMethodName(IEspContext &context, const char *methname, StringBuffer *methQName)\n", name_); - outs("{\n"); - - outs("\tif (!methname || !*methname)\n"); - outs("\t{\n"); - outs("\t\tif (methQName!=NULL)\n"); - outs("\t\t\tmethQName->clear();\n"); - outs("\t\treturn true;\n"); - outs("\t}\n"); - - outs("\tstd::string methodName(methname);\n"); - outs("\tstd::transform(methodName.cbegin(), methodName.cend(), methodName.begin(), tolower);\n"); - outs("\tauto it = m_qualifiedMethodNames.find(methodName);\n"); - outs("\tif (it != m_qualifiedMethodNames.end())\n"); - outs("\t{\n"); - outs("\t\tif (methQName != nullptr)\n"); - outs("\t\t\tmethQName->set(it->second.c_str());\n"); - outs("\t\treturn true;\n"); - outs("\t}\n"); - - outs("\treturn false;\n"); - outs("}\n"); - - //method ==> qualifyServiceName outf("\nbool C%sSoapBinding::qualifyServiceName(IEspContext &context, const char *servname, const char *methname, StringBuffer &servQName, StringBuffer *methQName)\n", name_); outs("{\n"); @@ -5565,6 +5547,7 @@ void HIDLcompiler::write_esp_ex_ipp() outs("#include \"SOAP/Platform/soapmacro.hpp\"\n"); outs("#include \"SOAP/Platform/soapservice.hpp\"\n"); outs("#include \"SOAP/Platform/soapparam.hpp\"\n"); + outs("#include \"SOAP/Platform/soaphidlbind.hpp\"\n"); outs("#include \"SOAP/client/soapclient.hpp\"\n"); outs("\n\n");