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..fa100642d07 --- /dev/null +++ b/esp/bindings/SOAP/Platform/soaphidlbind.cpp @@ -0,0 +1,52 @@ +/*############################################################################## + + 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(), + [](unsigned char c){ return std::tolower(c); }); + 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(), + [](unsigned char c){ return std::tolower(c); }); + auto it = m_qualifiedMethodNames.find(methodName); + if (it != m_qualifiedMethodNames.end()) + { + if (methQName != nullptr) + methQName->set(it->second.c_str()); + return true; + } + return false; +} diff --git a/esp/bindings/SOAP/Platform/soaphidlbind.hpp b/esp/bindings/SOAP/Platform/soaphidlbind.hpp new file mode 100644 index 00000000000..ef0503571b2 --- /dev/null +++ b/esp/bindings/SOAP/Platform/soaphidlbind.hpp @@ -0,0 +1,38 @@ +/*############################################################################## + + 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" +#include + +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 08cc6913654..1f6a8bf1d4c 100644 --- a/tools/hidl/hidlcomp.cpp +++ b/tools/hidl/hidlcomp.cpp @@ -30,6 +30,7 @@ #include #include #include +#include //------------------------------------------------------------------------------------------------------------- inline bool strieq(const char* s,const char* t) { return stricmp(s,t)==0; } @@ -3931,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 @@ -3940,6 +3941,7 @@ void EspServInfo::write_esp_binding_ipp() outs("\tvirtual void init_strings();\n"); outs("\tvoid init_metrics();\n"); + outs("\tvoid init_maps();\n"); outs("\tvirtual unsigned getCacheMethodCount(){return m_cacheMethodCount;}\n"); @@ -3958,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"); @@ -4080,16 +4079,17 @@ 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"); + outf("\tinit_maps();\n"); outf("\tsetWsdlVersion(%s);\n", wsdlVer.str()); outf("}\n"); @@ -4160,6 +4160,27 @@ void EspServInfo::write_esp_binding(const char *packagename) } outs("}\n"); + // 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) + { + outf("\t\t\"%s\"", mthi->getName()); + if (mthi->next != nullptr) + { + outs(",\n"); + } + else + { + 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"); outs("\tif(rpc_call == NULL || rpc_response == NULL)\n\t\treturn -1;\n\n"); @@ -4363,30 +4384,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"); - - for (mthi=methods;mthi!=NULL;mthi=mthi->next) - { - outf("\tif (Utils::strcasecmp(methname, \"%s\")==0)\n", mthi->getName()); - outs("\t{\n"); - outs("\t\tif (methQName!=NULL)\n"); - outf("\t\t\tmethQName->set(\"%s\");\n", mthi->getName()); - 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"); @@ -5548,6 +5545,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");