Entries Tagged 'OpenLaszlo' ↓

Flash, Flex & Web service problems

I always have a tough time deploying a Flash/Flex based app that uses web services. And we use web services (or similar) on almost all projects! Every two or three months I come across a new problem with web service deployment and have to spend some long hours finding and fixing it. The post describes my latest encounter with webservice errors and the fundamental lessons I’ve learnt about debugging PHP web services used in Flash/Flex/OpenLaszlo.

So, my latest web service error message was:
Request implements version: http://schemas.xmlsoap.org/soap/envelope/ Response implements

Well, that’s the only part I could read in the Alert message I had setup for faults in the web service. This was followed by the famous “could not connect to endpoint” error.

I was surprised looking at the error. First thing I did was check the WSDL file. (Yes, am using SOAP webservices). Tried different ways to generate the WSDL from Zend Studio (I use PHP5 web services and Zend Studio for development). Nothing worked. BTW, the problem came only on the live server. The development and staging servers were working perfectly fine with the same files!

After solving the problem, I re-learnt the biggest lesson in web service debugging.

Root cause of almost all web service related problems is some error / warning in your PHP (or other) code.

In this case, the server was not able to include classes and other files that the webservice was using. My PHP based test cases helped solve the problem since they showed up the include errors PHP was having. So let me give you the lesson # 2.

Make sure you write PHP test cases for your web services.

These test cases will use the SoapClient class to call a method on your webservice. Display all errors in the test cases and you will be able to nail the source pretty quickly.

This one is yet unsolved for me! I want to find out a good web service debugger. Something that allows me to pass arguments to the web service and see the entire request and response - including HTTP headers. The WebOrb admin panel does a great job at that, but I would like something that can easily handle complex data! Anything you know of?

Here are some earlier problems I have had with Webservices:

 

Laszlo code hinting with Dreamweaver

If you want to use Dreamweaver to edit your OpenLaszlo files (.lzx), here’s a forum thread that will give you all the tools needed.

The technique involves: adding in a TagLibrary for LZX and then setting .lzx as an HTML extension so that Dreamweaver can open and edit .lzx files. Worked with Mac for me. The procedure mentioned is for Windows.

 

Pandora: Identifying music

Learnt about a few interesting sites recently. They are quite unique and show excellent opportunities. They will shoot into the limelight very soon!

Pandora - discover musicThe first is Pandora. Pandora is a music discovery service that is based on the “Music Genome” project. Music Genome project was started about five years back to analyze the various types of music. Based on this research, they created Pandora.

You simply enter a keyword search and Pandora will pull out music that you may like. As you keep listening and noting which music you like and which you don’t, it automatically pushes music that you may like. The discovery engine is really good, and you actually get to hear music that you would like!

One more interesting thing about Pandora, is that it is written in Laszlo! The application interface is fluid and friendly. They have put up a great example of what can be done with Laszlo.

Go check it out!

Tomorrow: Identifying faces!

 

Funny characters, Webservices and UTF8

I was importing the Foss.In speakers and talks data into Glancer, and it started giving me some strange errors. This is what I got in OpenLaszlo:
error: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.

And when I tried using PHP, this was the string:
SOAP-ENV:Server SOAP-ERROR: Encoding: string 'some string here' is not a valid utf-8 string

So I looked up what’s causing this. First I thought it would be MySQL. I had mixed up collation order on different tables. Some were the default latin_swedish_ci, some were utf8_general_ci and some were utf8_unicode_ci. I changed all the tables and fields to utf8_unicode_ci first. But that did not solve the problem!

This is the time when I switched to PHP to test. And found that the problem was because the string in the data was not a proper Unicode / UTF8 string. I checked up if this is due to the size of the string - I had text data types. But well, that wasn’t the problem. Then I discovered the problem was coming up because of some funny characters in the text.

Primarily, the “auto convert” characters that Word typically adds up. E.g. the double quotes getting converted to inverted double quotes, three dots to an ellipsis, the TradeMark, so and so forth. This was not acceptable to the webservice!

This was strange to me, as Unicode should support any character in the world, but I just went ahead and removed all such characters and things started working!

FYI, here are the characters that I replaced:









 

OpenLaszlo - documentation typos

This is really a small thing, but can cost you a few minutes to figure out! The OpenLaszlo documentation has a few typos. The first I noticed, was the Debug.Write() instead of Debug.write(). There are other case mistakes like that. Generally these typos occur in the examples provided. If you see the LZX Reference, the actual method description will have proper method name, but the example at the top may contain wrongly typed method names.

Apart from the Debug.Write, the LzBrowzer.loadURL() is mentioned as LzBrowzer.LoadURL() . Now if you are like me, you will simply copy the code from an example and use it in your project. Assuming it would work. And when it doesn’t you are lost why does it not find a method with the name that you specified.

So keep this in mind!

BTW, I have a lot of other tips / tricks / feedback on OpenLaszlo… I am just waiting for Glancer to get over, so that I can write all of it!