Configuring the Server
You may be tempted to start your new server, but don'tit won't work. If you think about things for a second, you'll realize there's a couple of loose threads. For instance, the server does not know that the Tempconverter.wsdl document is related to the TempconverterService service. Nor does it know what URL should cause the TempconverterService service to be instantiated. Fortunately, the answers to these questions do not require any further coding. This information (and more, if necessary) can be setup in a simple XML configuration file.
<!-- Service binding -->
<!-- Service instances - implementation classes -->
After some initial (boilerplate) namespace declarations and server configuration, you arrive at the elements that control the service endpoint. Of the components in the <serviceEndpoint> attribute list, the ones you're concerned with are the wsdl and url attributes. The wsdl attribute describes the path to the service's WSDL document relative to the start-up directory of the server. The url attribute, obviously, specifies the URL of the service relative to the root of the HTTP server.
The use of the <cppa:instance> tag simply names this endpoint so that it can later be associated with a service instance as known to your server, i.e. your object code. This is done with the <serviceInstance> element. Here, you can see that name refers back to the serviceEndpoint/instance ref attribute, and class refers to the name of the class as specified in the WASP_FACTORY_DEFINE macro of your server. Save this file as config.xml (as dictated by the WASP_Runtime::serverStart() function).
With all the components in place, you can start your server.
Creating the Client
Servers aren't too interesting without their clients, so you'll want to develop a SOAP client to exercise your new service. I recommend creating the client code in the separate client directory you made earlier. If you do this, you'll want to copy over a few of the files that wsdlc generated.
$ cp Tempconverter.h Tempconverter.cpp TempconverterStructs.h \
shows a sample client that is even simpler than the Google client presented in Part I
. Save this client code as tcclient.cpp in the client directory, then compile and link it.
$ g++ -o tcclient *.cpp I/usr/local/waspc/include \
When you run this client, you should see the following:
70.00 degrees Fahrenheit = 21.11 degrees Celsius
70.00 degrees Celsius = 158.00 degrees Celsius
That's how easy it is to develop Web services in C++ or to expose existing C/C++ code as Web services!