ctkNetworkConnectorQtSoap.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * ctkNetworkConnectorQtSoap.h
  3. * ctkEventBus
  4. *
  5. * Created by Daniele Giunchi on 14/07/10.
  6. * Copyright 2010 B3C. All rights reserved.
  7. *
  8. * See Licence at: http://tiny.cc/QXJ4D
  9. *
  10. */
  11. #ifndef CTKNETWORKCONNECTORQTSOAP_H
  12. #define CTKNETWORKCONNECTORQTSOAP_H
  13. // include list
  14. #include "ctkNetworkConnector.h"
  15. // Foundation Library include list
  16. #include <qtsoap.h>
  17. namespace ctkEventBus {
  18. /**
  19. Class name: ctkNetworkConnectorQtSoap
  20. This class is the implementation class for client/server objects that works over network
  21. with soap protocol. It has been implemented only client side.
  22. */
  23. class org_commontk_eventbus_EXPORT ctkNetworkConnectorQtSoap : public ctkNetworkConnector {
  24. Q_OBJECT
  25. public:
  26. /// object constructor.
  27. ctkNetworkConnectorQtSoap();
  28. /// object destructor.
  29. /*virtual*/ ~ctkNetworkConnectorQtSoap();
  30. /// create the unique instance of the client.
  31. /*virtual*/ void createClient(const QString hostName, const unsigned int port);
  32. /// set the url of the wsdl for querying the service.
  33. void setWSDL(const QString wsdlUrl);
  34. /// set the action for the http transport
  35. void setAction(const QString action);
  36. /// set the path, for example the end point or the wsdl
  37. void setPath(const QString path);
  38. /// register a further namespace which will be used in soap 1.1 for axis2 compatibility
  39. void registerNamespace(QString prefix, QString namespaceURI);
  40. /// create the unique instance of the server.
  41. /*virtual*/ void createServer(const unsigned int port);
  42. /// Start the server.
  43. /*virtual*/ void startListen();
  44. /// Allow to send a network request.
  45. /** Need to convert the parameter list into another list of basic type to string which are used in QtSoap.*/
  46. /*virtual*/ void send(const QString methodName, ctkEventArgumentsList *argList);
  47. /// Marshalling of the datatypes
  48. QtSoapType *marshall(const QString name, const QVariant &parameter);
  49. /// return the response retrieved from the service
  50. QtSoapType *response();
  51. /// register all the signalsand slots
  52. /*virtual*/ void initializeForEventBus();
  53. //retrieve an instance of the object
  54. virtual ctkNetworkConnector *clone();
  55. Q_SIGNALS:
  56. /// signal for the registration of the functions with parameters
  57. void registerMethodsServer(mafRegisterMethodsMap registerMethodsList);
  58. public Q_SLOTS:
  59. /// register methods on the server
  60. void registerServerMethod(QString methodName, QList<QVariant::Type> types);
  61. private Q_SLOTS:
  62. /// retrieve response from the service
  63. void retrieveRemoteResponse();
  64. private:
  65. /// stop and destroy the server instance.
  66. void stopServer();
  67. QtSoapHttpTransport *m_Http; ///< variable that represents the soap request from client to server
  68. QtSoapMessage m_Request; ///< variable that represents the request
  69. mafRegisterMethodsMap m_RegisterMethodsMap;
  70. QString m_WSDLUrl; ///< represents the url of the wsdl
  71. QString m_Action; ///< represents the action to put inside transport http
  72. QString m_Path; ///< represents the path (for example the endpoint)
  73. QtSoapType *m_Response;
  74. };
  75. /////////////////////////////////////////////////////////////
  76. // Inline methods
  77. /////////////////////////////////////////////////////////////
  78. inline void ctkNetworkConnectorQtSoap::setWSDL(const QString wsdlUrl) {
  79. m_WSDLUrl = wsdlUrl;
  80. }
  81. inline void ctkNetworkConnectorQtSoap::setAction(const QString action) {
  82. m_Action = action;
  83. }
  84. inline void ctkNetworkConnectorQtSoap::setPath(const QString path) {
  85. m_Path = path;
  86. }
  87. inline QtSoapType *ctkNetworkConnectorQtSoap::response() {
  88. return m_Response;
  89. }
  90. inline void ctkNetworkConnectorQtSoap::registerNamespace(QString prefix, QString namespaceURI) {
  91. m_Request.useNamespace(prefix, namespaceURI);
  92. }
  93. } //namespace ctkEventBus
  94. #endif // CTKNETWORKCONNECTORQTSOAP_H