Fast Web Services Client with C++Builder Pro

So here’s the lowdown on how to get a web services client extremely quickly with C++ Builder Pro.

1.- The WSDL
Figure out a WSDL you want to implement. You could use the ASP Web Matrix project to create the simplest C# web service with add of two numbers.

2.- The UI
So we start with a typical empty project. Drop 2 Edit boxes and a statusbar with one status panel in it. Drop a button called “Call my webservice” or something hokey like that.

3.- Creating the C++ Client stubs
Call File->New->Other->Web Services->WSDL importer, and #include the header file in your form.

4.- Preparing a Client endpoint
Drop a THttpPrio component from the WebServices palette. Select your WSDL location (if you made the WebService using ASP.net, it will be something like http://localhost/MyClass.asmx?WSDL ). Select your service (MyClass) and your SOAP port (MyClassSoap).

5.- Tying it all together
Double click on the button to generate an onClick() event. Now type something along the lines of:


        String sNumber1 = edtNumber1->Text;
        String sNumber2 = edtNumber2->Text;
        int firstNumber = StrToInt(sNumber1);
        int secondNumber = StrToInt(sNumber2);

        // To obtain this, we called
        // File->New->Other->Web Services->WSDL importer, and
        // #included the header file.
        _di_MyClassSoap soapClass;
        myClassHttpPrio->QueryInterface(soapClass);
        if ( soapClass ) {
                int myResult = soapClass->Add(firstNumber, secondNumber);
                String myMessage = "Result: " + IntToStr(myResult);
                statusBar->Panels->Items[0]->Text = myMessage;;
        }

Done! You have a web service, go back to your server side and make C# multiply instead :-)

The point is, with this technology, no matter what the language is, the barrier of entry is extremely low. Do make sure you get a modern implementation for the language though (so you will have at least client tools). I’ve been going through the internals and the whole thing only looks trivial. :-).