Tuesday, May 25, 2010

Web Service development using NuSOAP on XAMPP and client in .net using C#

Recently, one of my customers wanted to expose their Web Services for the service users. They wanted to keep the data centralized in their website and allow it to be accessed by Desktop Client software on user’s consoles. As the Website is built using Wordpress as a CMS, all the data is managed well by Wordpress. So we started exploring a PHP based solution to create the web service compliant to Web Services Description Language (WSDL) 1.1. We finally zeroed on NuSOAP.

Getting started with NuSOAP was not at all a difficult job (Thanks to Scott Nichol’s tutorial). Once you get a feel of it, just follow his Programming with NuSOAP Using WSDL tutorial and you are done!

For the Web Service development, I preferred running the NuSOAP on my http://localhost using XAMPP. I already had the wordpress with test data readily installed there in. As I was developing the Desktop Client App using .net, I felt it comfortable to have both NuSOAP and client to be on my machine, for development phase.

Getting NuSOAP working on XAMPP was as easy as in following steps:

  1. Download the latest version of NuSOAP (Version 0.9.5, while writing this post)
  2. Download the documents (Optional)
  3. Extract nusoap-0.9.5.zip and copy the lib directory into a folder in XAMPP environment. I created a folder webserv under my C:\xampp\htdocs\ folder and copied the lib directory there.
  4. Create a web service script. e.g. server.php in webserv folder. And in the server.php include the nusoap.php file. (Refer to the code snapshot below)

/*********** server.php ***************************************/

/* including MySql Database wrapper functions and config file */

/* including new soap functions */


$server = new soap_server();
/* B2BManager is the name of web service */

Now you will be able to use NuSOAP calls in your web service, such as $server->register & $server->wsdl->addComplexType, as required.

After the Web Service setup, next thing was to request these services from the Desktop Application. This can be done by adding web service as a “Web Reference” in the .net solution. Following steps are involved in creating “Web Reference” in .net solution:

Add the Web Service URL, Discover and Add Reference. In the current example, the URL is : http://localhost/webserv/server.php?wsdl. Once this URL is entered, it will discover the services available. In this example, it discovered 1 service, i.e. B2BManager.




Note: In case there’s any problem with the server.php, the generated WDSL may not be well formed. This results in failure in discovering the services. Try navigating to the URL on any browser to see, if the WSDL is proper. If the WSDL is proper, you should see a well formed XML stream as an output. (For e.g. try navigating to Amazon Web service; URL: http://webservices.amazon.com/AWSECommerceService/US/AWSECommerceService.wsdl.

Call the web service in your code. Declare the web service variable in the class that you want it to be called as below:

B2BManager.localhost.B2BManager webService_ = null;

webService_ = new B2BManager.localhost.B2BManager();


Sunday, May 2, 2010

Resource Booking and Availability Calendar Plugin for Wordpress

Resource Availability & Booking Calendar plugin for Wordpress allows you to show the availablity status of any resource on the Calendar to the visitors and allows the resource vendors (admin users in Wordpress) to change the booking states on the Calendar.


One of my clients had requirement for a Calendar that shows the availability status of the resources such as Hotel rooms, Taxi for hire, etc. These resources belonged to multiple suppliers and the booking/reservation of the resources would be controlled by the respective resource vendors.


Upon discussing the use cases and the look & feel requirements with my client, we zeroed on using a AJAX implementation for the Calendar, so that we can fetch months of booking data without refreshing the resource details pages. Then we stumbled upon a free source, Ajax Availability Calendar developed by Christopher Bolson. Since my client’s existing website was built using Wordpress, I started adopting this cool code into a Wordpress plugin. The result is a Resource Booking & Availability Calendar plugin for wordpress.

Features in version 1.0

  • Open Source and FREE to use in your site or application
  • Unlimited Items (holiday homes, apartments etc.).
  • Booking States: Available, Booked, Provisionally booked.
  • Multiple administration users, with their own resource handling.
  • Styled with CSS - easy to adapt to any design.
  • Uses AJAX to change months viewed without reloading the page.
  • All javascript handled by the Mootools library.


You can download the latest version of this plugin from Wordpress Plugins database. The plugin is released under GPL2 license.

Installation and Usage

How to install the plugin and get it working?

Follow these simple steps:

  1. Download the plugin and extract it. Upon extraction, you will get `resource-booking-and-availability-calendar` folder.
  2. Upload `resource-booking-and-availability-calendar` folder to the `/wp-content/plugins/` directory
  3. Activate the plugin through the 'Plugins' menu in WordPress

How do I update the bookings in Calendar?

Go to edit post in Wordpress. Select the desired post. In the edit screen, you will see the option to enable Booking. If you enable booking, the Booking Calendar is displayed. Click through the desired dates to alter the booking status on each day.

How do I show the availability calendar to users?

Once you enabled the Booking on a post as said above, the users visiting that post will see the Availability Calendar at the end of the post content.


  • Availability Calendar - This is the public view of Availability Calendar on the posts for which Booking is enabled.


  • Booking Calendar - This is the Admin view of Calendar. If the Booking is enabled by checking the radio button, the Booking Calendar is loaded. Click on the desired date to change its booking status.


Change log

Version 1.0.1 – Snapshots uploaded in gif format

Adding your Plugin to Wordpress Plugin directory

Do you want to host your wordpress plugin in wordpress plugin database? Start here.

The first step before you actually submit your plugin, is to have yourself registered at wordpress.org. Well, registration seems very easy. But, if you have a dot separated email id like mine, be ready to see the error:

There was a problem with your email; please check it.

I think, it treats the stuff after the first dot as the email provider domain and hence treats it as invalid email. If you have google email, then my technique will work for you. Google allows your email without the dots, also to be your email. e.g. if your email is xyz.123@gmail.com, google allows you to use  it as xyz123@gmail.com. So, provide dot free email while registering for wordpress.org account. You will get the password mailed to you in few minutes.

Next, you need to get the access to the wordpress.org subversion (SVN) repository where you can put your plugin. Fill this form to request the access to repository. Fill all the fields carefully, as the repository will bear exactly the same names.

What next?

Wait … Wait … Wait for the approval of your request. Usually it takes hours to get the approval. It took almost 8 hours to me. You will receive a mail with details of the SVN and few helpful links listed below:

Here's some handy links to help you get started.
Using Subversion with the WordPress Plugins Directory
FAQ about the WordPress Plugins Directory
WordPress Plugins Directory readme.txt standard
readme.txt validator:

Well, now you can head on to check-in your plugin code in the SVN. You can download the latest SVN client from Tigris.org and install it. Then, follow these How to Use Subversion instructions.

Friday, April 16, 2010

SMF 1.1.11 Upgrade Error: The Upgrader found some old or Outdated Language Files

Its always fun to work with free/open source software :) SMF forum software is one such thing. Every time I feel a sense of achievement; especially after my website is well indexed and experiencing a surge of visitors.

Well, after the fix as explained in my previous post, I got few calls from my forum members saying “I can’t see my Personal Messages”, “I can’t view my own profile” and so on…

I started doubting the fix and planned to do a “large upgrade”, as its no harm and any database table discrepancies would also get fixed. It was as simple as following the steps:

But while copying the new files to your forum directory, you need to be very careful and make sure all the new source files are copied properly… or else the following error is certain and the update will fail:

Upgrade Error: The Upgrader found some old or Outdated Language Files

But, in my case, the problem was little different. I had used few mods & templates that used utf-8 language dependencies. Hence, even after copying the files properly, I got the above said error. Forum Maintenance tools were very helpful here. I could easily trace that the language files *.english-utf8.php (in folder smf_1-1-11_upgrade\Themes\default\languages of the downloaded SMF upgrade package) were mismatched in version. I started looking for latest version of utf-8 version of english language, but I couldn’t find them. (Actually I had got them bundled with the theme).

I was pretty sure, I had not used any support for other languages except plain ‘english’. So, I simply made copies of language files that were part of new SMF package and renamed the file names from *.english.php to *.english-utf8.php. This fix got me going with upgrade process…

That’s not all! While upgrading, it threw a cool warning …

Updating and creating indexes...
    Updating indexes on "messages"... done.
    Updating table indexes... done.
    Reordering boards and categories... done.
    Updating indexes and data on "smileys"... Unsuccessful!

This query:

ALTER TABLE smf_smileys
Caused the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LENGTH(code) DESC' at line 2

This one was easy to resolve, seems like classic problem! This post was extremely helpful. Simply follow those steps if at all you get this above said “Smiley” issue.

Finally my forum is up .. but my member complaints are not yet addressed. I guessed the complaints were related to some issue with the “Permissions” in SMF forum. Yes, it was ! Somewhere in the process of error checking the database and repairing the tables, the “permissions” had somehow got ignored. Once I set all the “Permission” as I wanted them to be, the forum is UP and Running normal (I think).

Thursday, April 15, 2010

SMF – Database Error and Forum Maintenance

Well, even if you keep your SMF forum updated regularly, you can’t avoid few weird things (Remember Murphy's Law?). I had a stint with such an error with SMF forum. When I navigate to my forum, it threw a Database Error. Not much information was available on that screen. I logged into the database to trace any errors (logged in smf_log_errors) using phpMyAdmin.

As I wrote in previous post, I did a repair of all the tables of SMF database, using phpMyAdmin. This fixed the problem as much to allow me to log into the forum and reach the Admin area.

SMF has given few tools for forum maintenance, as listed below:

Optimize all tables to improve performance.
Check all files against current versions.
Find and repair any errors.
Recount all forum totals and statistics.
Empty out unimportant logs.
Convert HTML-entities to UTF-8 characters

Before touching any of these, I prefer taking a backup. SMF Admin area provides a tool for that too in “Forum Maintenance - Backup Database” section. Please do take a backup; it helps in case the forum maintenance tools go insane.

After the backup, command “Find and repair any errors”. Hmm… here the story starts..It diagnosed an error and possible fix. Here it is …

Note: It appears that your database may require an upgrade. Your forum files are currently at version SMF 1.1.11, whereas your database is at version SMF 1.1.5. It is recommended that you execute the latest version of upgrade.php.

This happens as a result of improper upgrade of the forum software. On every patch release, the SMF update functionality provided in the SMF admin area can be executed to keep it up-to-date. This update script sometimes skips updating the mySQL database tables. Version to version, there could be some changes to the database tables. If such database updates are skipped or failed internally (Update doesn’t display these warnings/failures), it will leave the database in the old version and all other sources will get updated to latest release! Strange thing is, after the update, your forum is running smoothly … until a day, when you see “Database Error”. (Note: I don’t know the reason for Why it worked smoothly first?)

After digging through lot of posts/forums on net, I found a solution appreciated by many here. But, I was not lucky with that. It reported that “the sources and language files are not the latest ones”. Upon my continued search on net, I got a clue on how to fool this script not to throw the above said warning and somehow get on to forum maintenance. Well, its as simple as running the following SQL query.

UPDATE `smf_settings` SET `value`='1.1.11' WHERE `variable`='smfVersion' LIMIT 1;

Now, you should be able to do “Find and repair any errors”. This will do some helpful stuff.  Then, do “Empty out unimportant logs”; this will cleanup the extraneous logs that add unnecessary weight on you database. And do a “Recount all forum totals & statistics”.

It should bring life back to your SMF forum.

Note: These are the steps followed by me as an immediate fix, to at least bring up my forum. So, I don’t know the actual cause of the error. Time & usage will tell us whether it has really worked. At the same time, I am scout for a good, clean & elegant forum software. I will keep you updated.

Wednesday, April 14, 2010

SMF Error: smf error 2: Unable to save result set

I have been using SMF forum software for almost 2 years now. This is one of those freely available forum software, and I found it as the one that is easy for customization and is easy to use. The ‘Ease’ factor drastically falls, if you look at the source code, though. But, I always prefer open source for in case of crash/ or no-support, I can get my hands dirty and straighten it.

Today my SMF forum crashed throwing,

smf error 2: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Unable to save result set

I looked into the database using, phpMyAdmin tool that my web hosting provider has given. I started checking through the “smf_log_errors” table to find out the cause. It had several errors, including simple logs such as “login password is not matching” and stuff like that .. and I also found the above quoted “Unable to save result set”. Then, I analyzed the table “smf_log_errors” using phpMyadmin. I found the following errors:

smf_log_errors    analyze    Error    Table './my_smf_log_errors' is marked as crashed and should be repaired

smf_log_errors    analyze    Error    Table 'smf_log_errors' is marked as crashed and should be repaired

smf_log_errors    analyze    error    Corrupt

I though, it would all be fine if I “repair” only this table. But it didn’t work that way. I had to finally repair all the tables.

In case you find similar issue, please do a ‘repair’ of all tables in the respective database.

Following are the steps (listed for quick use):

  1. Open the respective database using myPhpAdmin tool. You need the username and password for the database. In case you have forgotten, check out the “/forum/Settings.php” file for username and password. You will find them assigned to “$db_user” and “$db_passwd”.
  2. Do Select All of all tables.
  3. Repair by selecting “Repair table” action. You can also check the errors by selecting “Analyze table”.

Now, you SMF forum should be back to working.

As I analysed the whole problem, it looks like, the cause for this kind of errors is the over grown “smf_log_errors” table size. So, I recommend deleting the read error logs, once in a while.

Monday, April 12, 2010

Why Android Music Player doesn’t have Equalizer?

Equalizer has been a standard feature in music players on almost all mobile phones nowadays. Unfortunately, Android phones doesn’t have it, due to limitations of Android platform.

Who is the culprit?

Android platform makes use of PacketVideo OpenCORE multimedia framework for Audio/Video support. OpenCORE framework doesn’t provide support for a generic equalizer implementation. Equalization is a process of increasing or decreasing the signal strength for a portion of (a band of) audio frequencies. Equalization in an Audio playback is achieved through ‘post processing’ of the decoded data of digital audio packets. Though, OpenCORE takes care of third-party codec integration (well, its bit tricky too…) and hardware codec integration, the framework is not designed to support integration of third-party post processing modules or plugins.

Is it really required?

In audio, there’s no commonly accepted ‘best sounding’ factor. What sounds best to a person may not sound best to others. In audio, ‘Best sounding’ depends on lot of factors such as listener’s taste, mood, and even the perception of sound by listener’s ears. This calls for tuning the audio output to one’s taste. Though, we all appreciate ‘flat frequency response’ of a sound system, many of us would like to tune it to some extent at least to take care of the ‘general’ discrepancies of the perceived sound by our ears (See, Fletcher-Munson Curves for a detailed discussion on this matter).

No support for ‘post processing’ plugins can prove to be a significant disadvantage in any multimedia framework. Years of research and work has gone into DSP algorithms to achieve finest tuning of the audio playback as per one’s listening tastes. Consider Windows Media Player for example; It has wide range of plugins available to enhance the audio playback. There are open source frameworks such as GStreamer and VLC, for which there are many developers contributing DSP post processing effects, worldwide. Having no support for such plugins renders a framework less friendly for contributors and consequently, the player applications based on such frameworks would be less attractive to many users.

Aren’t there any such frameworks readily available?

At first I wondered why Google adopted OpenCORE, when we have well proven multimedia framework, GStreamer for which so many codec support and plugins are already available. But, there are quite lot of issues in adopting open sources that are GPL or LGPL, especially in products that also features manufacturer’s Intellectual Properties (IP). I think, with this vision of making the platform mobile device manufacturer friendly, Google might have selected OpenCORE as the multimedia framework for its Android platform. OpenCORE is licensed under Apache License, Version 2.0, which allows us to change the adopted source code without mandating us to include the changed source code in the derived product.