Outils pour utilisateurs

Outils du site


cours:service_oriented_computing_and_web_services:2017-2018:gsoap

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
cours:service_oriented_computing_and_web_services:2017-2018:gsoap [2018/04/12 06:45]
tigli [gSOAP]
cours:service_oriented_computing_and_web_services:2017-2018:gsoap [2018/04/12 15:35] (Version actuelle)
tigli [How to publish a WSDL of a web service using gSOAP]
Ligne 2: Ligne 2:
 ====== ​ gSOAP ====== ====== ​ gSOAP ======
  
-[[+In this tutorial, we are going to use gSOAP Toolkit. Because gSOAP is working on a lot of OS, I suppose you chose Linux and potential embedded and/or optimized linux like Raspbian on Raspberry Pi. 
 + 
 + 
 +==== gSOAP Toolkit Installation ==== 
 +||
 [[https://​sourceforge.net/​projects/​gsoap2/​files/​|gSOAP Toolkit]], Development toolkit for Web Services and XML data bindings for C & C++  [[https://​sourceforge.net/​projects/​gsoap2/​files/​|gSOAP Toolkit]], Development toolkit for Web Services and XML data bindings for C & C++ 
  
Ligne 8: Ligne 12:
  
  
-||+||
 + 
 +==== A Quick How-To ==== 
 +([[http://​www.cs.fsu.edu/​~engelen/​soap.html|Original Reference]]) 
 + 
 +== wsdl2h ==  
 + 
 +We use the gSOAP '​wsdl2h'​ WSDL parser to obtain the gSOAP header file specification of a Web service from a WSDL document. 
 + 
 +To obtain a header file from a WSDL document, run '​wsdl2h'​ on a WSDL:  
 +  
 +** wsdl2h -o outfile.h infile.wsdl ** 
 + 
 +where infile.wsdl can be a resident WSDL file or a Web location of the WSDL. The outfile.h is the generated output file.  
 + 
 +For example:  
 +  
 +// wsdl2h -o XMethodsQuery.h http://​www.xmethods.net/​wsdl/​query.wsdl // 
 + 
 +This generates the header file XMethodsQuery.h. The header file defines the service in a more familiar C/C++ header format that you can browse within your IDE. 
 + 
 +== soapcpp2 : gSOAP Compiler == 
 + 
 +Now, we run the gSOAP compiler '​soapcpp2'​ on the gSOAP header file to produce the source code to implement the client application. The '​soapcpp2'​ stub and skeleton compiler generates proxies (and RPC stubs) for your client application as follow : 
 + 
 +{{ :​cours:​service_oriented_computing_and_web_services:​2017-2018:​client.gif?​700 |}} 
 + 
 + 
 +The gSOAP runtime library provides a transport layer with an HTTP stack on top of TCP/IP as well as secure SSL and DIME/MIME attachment support. 
 +To develop a service application,​ run the gSOAP '​wsdl2h'​ parser on a WSDL to create a gSOAP header file. The header file is compiled with the '​soapcpp2'​ compiler as follow:  
 + 
 + 
 +{{ :​cours:​service_oriented_computing_and_web_services:​2017-2018:​server.gif?​700 |}} 
 + 
 +The '​soapcpp2'​ compiler generates the C/C++ Web service skeletons. You can also take a legacy C/C++ application and develop a service simply by entering the C/C++ Web service method operations and data types into a header file. The '​soapcpp2'​ compiler generates the source code for your project and produces a WSDL to advertize your Web service . 
 + 
 + 
 +==== Tutorial : Getting Start with gSOAP ==== 
 + 
 +Here you can find a complete step by step tutorial to write yuor first SOAP and REST Web Services, from Hello World to the classical Calc :  
 [[https://​www.genivia.com/​dev.html|Getting Start with gSOAP]] [[https://​www.genivia.com/​dev.html|Getting Start with gSOAP]]
 +
 +
 +
 +==== Publish the WSDL of your web service using gSOAP ====
 +||
 +[[https://​www.cs.fsu.edu/​~engelen/​soapdoc2.html#​tth_sEc19.10| In HTTP GET Support ...]] find an example that  produces a WSDL file upon a HTTP GET with path ** ?wsdl **
 +
 +<​code>​
 +
 +int http_get(struct soap *soap)
 +{
 +   FILE *fd = NULL;
 +   char *s = strchr(soap->​path,​ '?'​);​
 +   if (!s || strcmp(s, "?​wsdl"​))
 +      return SOAP_GET_METHOD;​
 +   fd = fopen("​myservice.wsdl",​ "​rb"​);​ // open WSDL file to copy
 +   if (!fd)
 +      return 404; // return HTTP not found error
 +   ​soap->​http_content = "​text/​xml";​ // HTTP header with text/xml content
 +   ​soap_response(soap,​ SOAP_FILE);
 +   for (;;)
 +   {
 +      size_t r = fread(soap->​tmpbuf,​ 1, sizeof(soap->​tmpbuf),​ fd);
 +      if (!r)
 +         ​break;​
 +      if (soap_send_raw(soap,​ soap->​tmpbuf,​ r))
 +         ​break;​ // can't send, but little we can do about that
 +   }
 +   ​fclose(fd);​
 +   ​soap_end_send(soap);​
 +   ​return SOAP_OK;
 +
 +
 +</​code>​
 +
 +==== Test the interoperability ​ ====
 +
 +After deploying the calc WS-SOAP, test its interoperability with a typical WCF client.
 +
 +==== Use gSOAP for monitoring ====
 +
 +Of course, this low level programming approach is not very useful to write classical services without any system challenge.
 +
 +On the other hand, as soon as you want to access to specific Operating System and even kernel API, such an approach seems interesting. ​
 +
 +To illustrate that choose your own prefered POSIX function and test it through a Web Service gSOAP. ​
 +If you don't have imagination try // getpid() //.
  
  
cours/service_oriented_computing_and_web_services/2017-2018/gsoap.1523508326.txt.gz · Dernière modification: 2018/04/12 06:45 par tigli