How to add a Web Service to a Delphi 2006 app? - web-services

I have an application developed with Delphi 2006 using Indy 10. Does anyone know how to add the executable file a WebService feature so users can interact with it via SOAP? I've seen that the examples provided by Delphi need to have Indy 9, and since our application depends on Indy 10, going back to 9 is not an option, and unfortunately I haven't seen any other packages to provide this functionality.

With the current release 10.5.7 of Indy (Tiburon branch) I sucessfully used this article to write a simple stand alone SOAP Server with Delphi 2009:
http://www.digicoast.com/delphi_soap_standalone.html
It should work fine with Delphi 2006 too (I am using the Indy 10 Tiburon branch even in Delphi 6).
The SOAP service can be consumed with Java (JAX-RPC) web clients, but I have not tested all possible datatypes.

What if you encapsulated your logic into an Apache module (you will end up with a TWebModule) and serve it using Apache?

I use remobjects sdk for this. IIRC it works with both Indy 9 and 10. Might be a bit expensive for you though. http://www.remobjectssdk.com/

Related

SOAP server and client application VCL+indy demo for Delphi XE?

Delphi used to include a demos folder for web Services, but no longer seems to include this.
I just tried the Delphi 7 demo projects (SOAPDMServerWAD, a server with almost no UI at all, and SOAPDMClient) and was unable to get them to function, even in Delphi 7.
If anybody has ever made a similar demo work in Delphi XE, or Delphi 2010, identical to the old SOAPDMServerWAD+SoapDMClient demos, working in Delphi XE, and with at least the minimal UI that comes from the Delphi SOAP Server application wizard, that would be perfect.
Update: The demo appears all the way up to Delphi 2010 but uses the now-obsoleted WAD (web-app-debugger), I tried to port it to the new Indy runtime/web-app-development-harnessing-code, but I can't seem to get it working. The demo runs, but the server has no User interface, and does not appear to be running any HTTP server (tested using a regular web browser, via http://localhost:port/ urls. By the way, try googling for a demo, and this url comes up, and I asked less than an hour ago. That's scary, google.
Update2 See my own answer below, a link is coming soon with working code.
I have posted the complete set of demos for SOAP on CodeCentral as item 28789.
These contain every single one of the Delphi 2007 era SOAP demos from the WebServices folder, now updated for Delphi XE and XE2, including converting the old WAD servers into new INDY VCL servers. You'd think that was impressive, except it's not. It's really easy. Just use the wizard to create a new project, and then add the web service interface and implementation units, and any other units that belong in the old demo, to the project. Once they're added to the project, they just work. Basic demo SOAP Servers are really easy to build in Delphi, once you have a working demo, you'll find it's pretty easy to modify and extend it.
The demo that best answers the question I asked above is in the SOAPDataModule sub-folder.
The basic problems with the demo from the 2007 era are two:
The WAD (web app debugger) is gone. you have to make a new server using the Indy server, for optimal demo purposes, saving you from using WAD (which is gone) or setting up ISAPI environment, under IIS, which is hardly ideal for demo purposes. The new demo project I made is called SoapDMServerINDY, and it consists of a data module (datamod_u.pas), a VCL form User Interface unit (IndyServerVCLFormUnit.pas) and an Indy Server web module, called IndyServerWebModule.pas.
The Delphi 2007 demo broke thanks to the new practice of having a Debug/Win32 subfolder that the demo executable is now in, you need to go up further. I fixed the demo server so that it warns you with an error message if the data files cannot be located, saving you from the mysterious "XML parsing error". I also added some error checking in a few of the demos so that it tells you that you need to install interbase for this demo to work, since some of the demos require Interbase installed and running, and one requires an alias called IBLOCAL to exist, and preferably a table called EMPLOYEE to exist.
The elements of this demo are a server (SoapDMServerINDY, based on the code from SOAPDMServerWAD), and the client SOAPDMClient which connects to the demo and has two pages, one page will show basic data access via a DBGrid + dataset remoting, and the second page shows how to invoke a custom SOAP method.
To use the demo: You have to start the server, click the start button, then start the client and click Connect.

C++ Library for implementing a web services api over legacy code?

Does anyone know of any really good C++ Libraries for implementing a web services api over top of existing legacy code?
I've got two portions that are in need of it:
An old-school client/server api (No, not web based, that's the problem)
An old cgi application that it integrates with the client and server.
Let me know if you've had any luck in the past implementing something like this using the library.
Microsoft has put out native code webservices API (WWSAPI) that looks pretty decent. I haven't had a chance to use it yet. We had originally ignored it, since it required Windows 7 or Server 2008, but they've finally released a runtime library for older OSs.
I would advise staying away from Microsoft's old SOAP SDK. For one, it's been deprecated; two, it's not terribly easy to distribute; and three, it's terrible to code for compared to the .NET offerings.
What we've done is written a bit of C++\CLI to interface our existing C++ codebase with .NETs webservice framework. This turned out to be remarkably easy. .NET will generate all the classes and boilerplate code you need based of of a WSDL file. Then you just write some C++\CLI code to handle the incoming data as managed classes and fill in some managed classes as responses.
You can use the Apache AXIS/C interface to build a web services interface. It has plugins for Apache and IIS (and I think FastCGI), and lets you talk web services to your legacy code.
I used gSOAP in a project and it was quite straightforward. Compared to Axis/C, I found it easier to learn and use. I never used POCO, can't give you an opinion, but it's gaining popularity recently. This is the link for gSOAP
http://www.cs.fsu.edu/~engelen/soap.html

How to use MS SOAP toolkit?

I know that the Microsoft SOAP toolkit has been deprecated for a while now (.NET has all this stuff built in) but I was wondering in anyone has a quick bit of info on setting up a simple app that uses it. I was referred to
http://www.devarticles.com/c/a/Cplusplus/Building-A-SOAP-Client-With-Visual-C-plus/
but the service in the example is no longer functioning and I can't seem to find any documentation online.
I've looked into gSoap, but it seems overly complicated for what I have to do and despite not being able to get it to work, the SOAP toolkit seems (relatively) elegant.
Don't do it. It's 5 years deprecated, and it was 2 years out of date when it became deprecated. Don't.
Assuming you are running on Windows (since you mentioned the MS SOAP Toolkit), use the imminently-arriving WWSAPI instead.
Also see this post:
http://blogs.msdn.com/vcblog/archive/2009/03/31/interested-in-using-web-services-in-your-native-c-c-code.aspx
EDIT: If you want something more basic, you can use MSXML and build your SOAP requests manually.
Really. "Deprecated" is not the word for it. It's at the top of my list of obsolete web service technologies:
SOAP Toolkit
WSE 1.0
WSE 2.0
WSE 3.0
ASMX - not quite obsolete. Just "legacy".

C++ web service framework

We are looking for a C++ Soap web services framework that support RPC, preferably open source.
Any recommendations?
WSO2 Web Services Framework for C++ (WSO2 WSF/C++), a binding of WSO2 WSF/C into C++ is a C++ extension for consuming Web Services in C++.
http://wso2.org/projects/wsf/cpp
Apache Axis is an open source, XML based Web service framework. It consists of a Java and a C++ implementation of the SOAP server, and various utilities and APIs for generating and deploying Web service applications.
http://ws.apache.org/axis/
http://code.google.com/p/staff/
Staff is Web Service Framework for C++ (service/component and client-side)/JavaScript(client-side) based on Apache Axis2/C.
Open-source, released with Apache License V2.0.
Try the ffead-cpp framework, it provides in-built web-service support, rest, json and many other useful features.
We are using EasySoap (http://easysoap.sourceforge.net/)
While not FOSS another library is ATL Server library from Microsoft.
It is C++ template based with some proprietary attributes by Microsoft. i.e. not standard C++
You can check out xmlbeansxx. This is a kind of lightweight, low level solution, compared to complete frameworks. This has advantages in some cases.
Invoking SOAP WebServices using xmlbeansxx Article
Code example is here:
WsClient.cpp.
You could try gSOAP. Available under GPL and commercial licences.
I have used SWIG to make an interface from C++ to Java or Python and then used the typical web interface support for those languages.
Since Java and Python have reflection the web services frameworks that exist for them have a much easier time passing data around.
Threading wise if your C++ code is thread safe you can let the Java server manage the creation of threads for concurrent requests etc. and just call into your C++ code using JNI.
As a bonus you can test your C++ code from Python using these same SWIG interfaces.
I think the way to go is to write your service in C++ (I am assuming you did all the homework and there is a good reason you want to write in C++) and then front it using an RPC server. Use something like Thrift or Protobufs for a fast RPC implementation.
Now write your web frontend in the language of your choice - python would be mine - and make RPC calls to do all your heavy lifting.
POCO Remoting gives you a very simple way of creating web services in C++ by just annotating C++ class definitions with special comments and running a code generator over it. It's commercial, but delivered with full source code. A free eval version is available. Runs on Windows, Linux, Mac OS X, etc.
I concur with imjorge's answer and add that there's a C/C++ version of the Axis2 framework (a more flexible, extensible Axis) that does SOAP via RPC and all sorts of stuff including a bunch of the WS-* specs.
http://ws.apache.org/axis2/c/
Apache axis-c:
Simple to use, but seems abandoned.. not even download pages is working for several months
WSOF WSFCPP:
Fast quickstart dev, both binded or no-binded implementation, based on Apache AxisC and it seems most of the current developers of Apache Axis is from WSOF company. Besides the Great potential I've detected a memory leak.
I'm currently using Gsoap and It has very good performance.
Gsoap "mixed notation" between old c style and some (bad?) practices for C++ bothers me some.. but this is only code-furniture.
POCO:
Is a full-feature, modern (java?) like library. It is open source software, licensed under the Boost Software License 1.0. You'll have to write some things from scrach, but with great support, utility classes and etc great library.. Innovations from c++11+ with all boost initiatives + POCO + a new Build/Dependency system more "gradle like" will certainly bring c++ to new areas of development.

How to consume a web service from VB6?

I need to consume an external web service from my VB6 program. I want to be able to deploy my program without the SOAP toolkit, if possible, but that's not a requirement. I do not have the web service source and I didn't create it. It is a vendor-provided service.
So outside of the SOAP toolkit, what is the best way to consume a web service from VB6?
I use this function to get data from a web service.
Private Function HttpGetRequest(url As String) As DOMDocument
Dim req As XMLHTTP60
Set req = New XMLHTTP60
req.Open "GET", url, False
req.send ""
Dim resp As DOMDocument
If req.responseText <> vbNullString Then
Set resp = New DOMDocument60
resp.loadXML req.responseText
Else
Set resp = req.responseXML
End If
Set HttpGetRequest = resp
End Function
.NET has a good support for Web Services since day one, so you can develop your Web Service client logic in .NET as a .dll library/assembly and use it in VB6 app via COM Interop.
Assuming that you're running on Windows XP Professional or above, one interesting method is to use the SOAP moniker. Here's an example, lifted from some MSDN page. I don't know if this particular service works, but you get the idea...
set SoapObj = GetObject
("soap:wsdl=http://www.xmethods.net/sd/TemperatureService.wsdl")
WScript.Echo "Fairbanks Temperature = " & SoapObj.getTemp("99707")
This mechanism also works from VBScript. Which is nice.
Pocketsoap works very well. To generate your objects use the WSDL generator. Using this you don't have to parse anything yourself, plus everything is nice and strongly typed.
Check out this article by Scott Swigart on the MSDN VB 6.0 Resource Center.
Calling Web Services from Visual Basic 6, the Easy Way
I've had some measure of success so far using PocketSOAP to connect to the Salesforce API. I could not use the WSDL Wizard because it generates wrapper class filenames using the first 23 characters of the call names, and this results in duplicates. Nevertheless, PocketSOAP has been working well enough for me without the wizard, and it's much more straightforward than using XMLHTTP with DOMDocument.
I also looked into making a wrapper in .NET or using one of the "MS Office {MSO version} Web Services Toolkit" libraries, but there were significant deployment hassles with those options. PocketSOAP is a simple COM DLL, not dependent on some particular version of MS Office, and is licensed under MPL.
The SOAP toolkit is arguably the best you could get. Trying to do the same thing without it would require considerable extra effort. You need to have quite serious reasons to do that.
The format of the SOAP messages is not really easy to read or write manually and a third-party library is highly advised.