A simple web service over HTTP library. Calls a HTTP server via GET, and returns the response wrapped in a XML parser. All calls are synchronous. Needs the NetServicesMin, DNSResolver, TcpLineStream and spxml libraries. The code for URL handling has been copied directly from the original NetServices library (Thanks to Donatien!).

Committer:
hlipka
Date:
Sat Jan 29 23:29:41 2011 +0000
Revision:
1:62e112d14c8f
Parent:
0:5e8527b638e1
Child:
2:687430e7f63a
Changed to use the TcpLineStream library. This makes the code much simpler.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 1:62e112d14c8f 1 #ifndef __WEBSERVICE_H__
hlipka 1:62e112d14c8f 2 #define __WEBSERVICE_H__
hlipka 1:62e112d14c8f 3
hlipka 1:62e112d14c8f 4 #include "spdomparser.hpp"
hlipka 1:62e112d14c8f 5
hlipka 1:62e112d14c8f 6 #include "url.h"
hlipka 1:62e112d14c8f 7
hlipka 1:62e112d14c8f 8 #include "tcplinestream.h"
hlipka 1:62e112d14c8f 9
hlipka 1:62e112d14c8f 10 /**
hlipka 1:62e112d14c8f 11 A simple web service over HTTP library. Calls a HTTP server via GET, and returns the response wrapped in a XML parser. All calls are synchronous.
hlipka 1:62e112d14c8f 12 Needs the NetServicesMin and DNSResolver library
hlipka 1:62e112d14c8f 13 The code for URL handling has been copied directly from the original NetServices library (Thanks to Donatien!).
hlipka 1:62e112d14c8f 14
hlipka 1:62e112d14c8f 15 */
hlipka 1:62e112d14c8f 16 class WebService
hlipka 1:62e112d14c8f 17 {
hlipka 1:62e112d14c8f 18 public:
hlipka 1:62e112d14c8f 19 /**
hlipka 1:62e112d14c8f 20 create the web service instance.
hlipka 1:62e112d14c8f 21 @params urlStr the URL to call via GET
hlipka 1:62e112d14c8f 22 */
hlipka 1:62e112d14c8f 23 WebService(const char* urlStr);
hlipka 1:62e112d14c8f 24 /**
hlipka 1:62e112d14c8f 25 Execute the web service call. Note that the caller is responsible for freeing the return parser instance.
hlipka 1:62e112d14c8f 26 @return the XML parser, or NULL if an error occured
hlipka 1:62e112d14c8f 27 */
hlipka 1:62e112d14c8f 28 SP_XmlDomParser *callService();
hlipka 1:62e112d14c8f 29 /**
hlipka 1:62e112d14c8f 30 close all resources
hlipka 1:62e112d14c8f 31 */
hlipka 1:62e112d14c8f 32 ~WebService(){close();};
hlipka 1:62e112d14c8f 33 /**
hlipka 1:62e112d14c8f 34 close all resources
hlipka 1:62e112d14c8f 35 */
hlipka 1:62e112d14c8f 36 void close();
hlipka 1:62e112d14c8f 37
hlipka 1:62e112d14c8f 38 private:
hlipka 1:62e112d14c8f 39 void init();
hlipka 1:62e112d14c8f 40
hlipka 1:62e112d14c8f 41 string _request;
hlipka 1:62e112d14c8f 42
hlipka 1:62e112d14c8f 43 TCPLineStream *_stream;
hlipka 1:62e112d14c8f 44 };
hlipka 1:62e112d14c8f 45
hlipka 1:62e112d14c8f 46
hlipka 1:62e112d14c8f 47
hlipka 0:5e8527b638e1 48 #endif