Release of tutorials for Web Services in Java, C#.NET and PHP

In a recent entry on this blog, we announced the release of a tutorial on Lokad Web Services in C#. Studies of programming language market shares suggest that the most popular web languages are Java, C#.NET and PHP; so we had decided to provide tutorials for this three languages.

We have just released tutorials for Web Services in Java and PHP, as well as an update of the C#.NET tutorial. Source code demonstrating the functionalities is also available. You can download them at:

  • Tutorial in Java
  • Tutorial in C
  • Tutorial in PHP

Web Services and interoperability

Lokad Web Services were initially developed in C#.NET; then we tried to create clients in PHP and Java to access them. This process highlighted some interesting interoperability issues.

Microsoft has included in the .NET framework a complete API to work with web services. It is at the same time simple, coherent and complete so it fully suits the needs of Lokad. Developing a client in C#.NET was really easy.

PHP did not raise specific problems. Since the language is not strongly typed, data types conversion are automatic (and not very secure). We used the NuSOAP toolkit which provided us with all the functionalities we needed. Low-level access to the requests helped us to set-up authentication.

Java was more difficult. Actually, Sun gives several APIs to develop Web Services servers and clients. We chose JAX-WS, the most recent and high-level of this APIs. Too bad this API is not fully compatible with Microsoft’s (or the other way round).

First problem we ran into was authentication. .NET uses a SOAP header to transmit user name and password. JAX-WS does not provide a simple way to add such headers. We had to develop a heavy workaround, in the form of a SOAP handler that intercepts all requests and adds the correct header. That very problem is often raised on Java forums and never answered… see source code if you are interested!

Another problem was that we initially had two Web Services: one dedicated to time-series and the other to forecasting tasks. .NET’s wdsl.exe can merge types when importing several WSDLs; Java’s wsimport can’t. Thus we ended with two identical but separate TimeSeries classes, one in each Web Service’s namespace! We finally solved this by merging the two Web Services. This also allows to instantiate only one SOAP client instead of two, so we believe it is a better design choice.