Gem #101: SOAP/WSDL server part
by Pascal Obry —EDF R&D
Let's get started...
This is the first part of a two-part Gem on SOAP (Simple Object Access Protocol).
In this Gem we will be building a SOAP server and you'll see that with Ada it is quite simple!
Let's take a simple package spec such as the following:
package Temperatures is type Celsius is new Float; type Fahrenheit is new Float; function To_Fahrenheit (C : Celsius) return Fahrenheit; function To_Celsius (F : Fahrenheit) return Celsius; end Temperatures;
The body is not shown here but it's part of the source packages that can be downloaded (see below).
The first step is to generate the WSDL (Web Service Description Language). A WSDL is an XML language for describing Web services. In the WSDL we find a description of the types and the specs of the routines. A WSDL is similar to an IDL but based on XML.
To generate the WSDL, AWS come with the ASIS-based ada2wsdl tool:
$ ada2wsdl temperatures.ads -a http://localhost:8888 -o temperatures.wsdl
The options are:
-a http://... Specifies the end-point for the Web services. -o temperatures.wsdl Outputs WSDL into temperatures.wsdl.
Out of this WSDL it's possible to generate stubs (for calling Web services) or skeletons (for implementing Web services). In this first part we're building a server, so we don't need the stubs. AWS comes with a second tool called wsdl2aws to generate all the necessary the code:
$ wsdl2aws -nostub -cb -spec temperatures -main soap_server temperatures.wsdl
The options are:
-spec temperatures To use the routines as implemented in Temperatures unit. -cb Generates the SOAP callbacks using the routines found in the spec specified above. -main soap_server Generates a main named soap_server, this main program starts the SOAP server by referencing a SOAP dispatcher using the callback routines.
Using the three options above is very handy for building a server that provides Web services and nothing more. The last actions are just to compile the server and run it:
$ gnatmake -gnat05 -Psoap_server $ ./server
At this point the services are available on the network and can be called by other programs, possibly built with other languages (Java and C# are the most common ones).
In the second part of this series we will see how to call those services from Ada using AWS.soap_server.zip
Last Updated: 10/13/2017
Posted on: 3/14/2011