![]() |
zeep::http::soap_controller — class that helps with handling SOAP requests
// In header: <zeep/http/soap-controller.hpp> class soap_controller : public zeep::http::controller { public: // member classes/structs/unions template<typename Callback, typename... > struct mount_point { }; template<typename ControllerType, typename Result, typename... Args> struct mount_point<Result(ControllerType::*)(Args...)> : public zeep::http::soap_controller::mount_point_base { // types typedef Result(ControllerType::*)(Args...) Sig; typedef std::tuple< typename std::remove_const_t< typename std::remove_reference_t< Args > >... > ArgsTuple; typedef std::function< Result(Args...)> Callback; // construct/copy/destruct mount_point(const char *, soap_controller *, Sig); template<typename... Names> mount_point(const char *, soap_controller *, Sig, Names...); // public member functions virtual void collect_types(std::map< std::string, xml::element > &, const std::string &); template<std::size_t... I> void collect_types(std::map< std::string, xml::element > &, const std::string &, std::index_sequence< I... >); template<std::size_t I> xml::element collect_type(std::map< std::string, xml::element > &, const std::string &); virtual void call(const xml::element &, reply &, const std::string &); template<typename ResultType, typename ArgsTuple, std::enable_if_t< std::is_void_v< ResultType >, int > = 0> void invoke(ArgsTuple &&, reply &, const std::string &); template<typename ResultType, typename ArgsTuple, std::enable_if_t< not std::is_void_v< ResultType >, int > = 0> void invoke(ArgsTuple &&, reply &, const std::string &); template<std::size_t... I> ArgsTuple collect_arguments(const xml::element &, std::index_sequence< I... >); template<typename T> T get_parameter(xml::deserializer &, const char *); virtual void describe(type_map &, message_map &, xml::element &, xml::element *); // public data members static constexpr size_t N; Callback m_callback; std::array< const char *, N > m_names; xml::element m_responseType; std::array< xml::element, N > m_parameterTypes; }; struct mount_point_base { // construct/copy/destruct mount_point_base(const char *); ~mount_point_base(); // public member functions virtual void call(const xml::element &, reply &, const std::string &) = 0; virtual void collect_types(std::map< std::string, xml::element > &, const std::string &) = 0; // public data members std::string m_action; }; // construct/copy/destruct soap_controller(const std::string &, const std::string &); ~soap_controller(); // public member functions void set_location(const std::string &); void set_service(const std::string &); template<typename Callback, typename... ArgNames> void map_action(const char *, Callback, ArgNames...); xml::element make_wsdl(); virtual bool handle_request(request &, reply &); };
This controller will handle SOAP requests automatically handing the packing and unpacking of XML envelopes.
To use this, create a subclass and add some methods that should be exposed. Then map these methods on a path that optionally contains parameter values.
See the chapter on SOAP controllers in the documention for more information.
soap_controller
public member functionsvoid set_location(const std::string & location);Set the external address at which this service is visible.
void set_service(const std::string & service);Set the service name.
template<typename Callback, typename... ArgNames> void map_action(const char * actionName, Callback callback, ArgNames... names);map a SOAP action to callback using names for mapping the arguments
The method in callback should be a method of the derived class having as many arguments as the number of specified names.
xml::element make_wsdl();Create a WSDL based on the registered actions.
virtual bool handle_request(request & req, reply & reply);Handle the SOAP request.