The WSDL Blower: The state of SOAP in Zend Framework 1.6
There are all kinds of ways to expose APIs as web services. SOAP, XML-RPC, REST, JSON-RPC. Out of all of these, SOAP is arguably the most complex, but also one of the oldest ways to expose an API (I remember preliminary SOAP and WSDL support in Delphi 6, circa 2001).
Exposing an API as a web service in Zend Framework is fairly straight forward, in fact it is (or should be) as easy as one, two, three:
- Pick your favorite style (Zend_Soap_Server, Zend_XmlRpc_Server, Zend_Rest_Server, Zend_Json_Server).
- Define a properly documented class with the methods and business logic that you want to expose.
- Let your Zend_*_Server::handle(); everything else.
That's pretty much it. Of course each Zend_*_Server has its own settings and options that you can (and sometimes must) configure. XML-RPC is also the only server that supports namespaces.
If you decide on using SOAP, there are a few things to watch out for.
- The WSDL generator doesn't let you set the TargetNamespace attribute explicitly. This becomes an issue when you're working with different environments (development, testing, staging, production, etc.) since the URL of the service determines the namespace. And that makes automatic code generation based on the WSDL problematic. I've contributed a patch to address this, as part of ZF-4117.
- Zend_Soap_Client contains a bug that prevents it from properly proxying method calls. Instead, it'll end up recursing infinitely, or at least 100 times before PHP detects the issue and kills it. The quick fix of removing a single underscore froma method call is outlined in ZF-4152.
- Zend_Soap_Server doesn't properly turn Exceptions into SoapFaults (due to lack of typecasting) as described in ZF-3958. You can still throw SoapFaults explicitly, but that's just bad form since your class shouldn't be SOAP specific. After all, you may decide to also expose it as XML-RPC or what have you, and then the SoapFault, while it might still work properly, is semantically incorrect.
- While Zend_Soap_Server and Zend_Soap_Client are mostly wrappers for the native PHP SoapClient and SoapServer classes, PHP itself lacks WSDL generation which Zend_Soap_AutoDiscovery provides in conjunction with Zend_Soap_Wsdl. Unfortunately the notion of "array of datatype" is not supported, since arrays in PHP are simply declared as "array" and can contain anything. Zend Studio's WSDL generator supports the syntax of "string[]" to specify an array of strings, and this works with complex types as well. "User[]" is an array of User objects. The issue is outlined in ZF-3900, to which I didn't provide one, but two patches, neither of which actually do what I thought they'd do (go me!). However, I have put together an embarrassing hack (Zend_Soap_Wsdl arrayOfType patch) that finally does work — at least for me. So far I haven't worked up the courage to submit it to JIRA. Not one of my finest moments.
I doubt most of these issues will hang around for long, but if you're developing something SOAPy with ZF1.6, you'll like encounter at least one of them.
Print This Post
Bugs in Phing on Windows
I use Phing to deploy my projects, and as they become more complex I expand on my use of Phing tasks. For instance, I have a ZIP archive of zip codes that Phing extracts and then imports into a database when deploying the application.
I maintain two development environments. One on a Linux server, and one locally on my Windows laptop using WAMP. So naturally, my PHP projects are cross-platform compatible and run on either Windows or Linux. And for the most part that simply means being careful about buildings paths, filenames, and file permissions.
To my surprise, the Unzip task defined in my build.xml that imports the Zip code data failed in mysterious ways: It reports success, but there's no extracted files to be found. It works on Linux, but not on Windows.
I dug into it and found two issues. First, the Phing's Unzip Task doesn't have the most solid error checking, and errors coming back from the Archive_Zip PEAR component. Second, the Archive_Zip PEAR component doesn't correctly check for absolute paths on Windows. Both problems have been reported on Phing's web site as Issue #261 and #262.
Print This Post
Ubuntu 8.04 on a Sony VAIO VGN-FE890
This is a follow-up to my Ubuntu post from a few days ago. I've tried out the final version of 8.04 LTS on my Sony VAIO laptop, and found that it didn't boot. Instead, after the Loading Kernel process bar reaches 100%, the only thing that appears on screen is:
[ 42.947514] ACPI: EC: acpi_ec_wait timeout, status 0, expect_event = 1 [ 42.947575] ACPI: EC: read timeout, command = 128
And unfortunately that's where it ends. No CTRL+ALT+DEL, the only way to turn off the laptop is to hold down the power button for 5 seconds.
So apparently there's an issue with the ACPI, and indeed, it's something that's already being talked about.
I didn't actually install Ubuntu on the laptop, but I wanted to check it out from the live CD. My workaround is to hit F6 twice in the boot menu — once to get a command line interface to be able to add and modify the options, and the second time you get a popup. From there, conveniently select the first option, which is "acpi=off", by hitting Enter. Press ESC to close the popup, and hit Enter to boot. Of course ACPI will be disabled, but at least you'll be able to get into Ubuntu.
Print This Post
PHP 5.0.2
Earlier I saw that PHP 5.0.2 is available. PHP 5.0.1 didn't fix any of our problems. I skipped this one and went straight to PHP 5.1.0-CVS, which I tested on our dev server. Recompiled PHP5, restarted Apache, and so far it looks solid. Very nice. That means that we can hopefully migrate our software to PHP5. Exceptions, Iterators, here we come.
Print This Post
More PHP woes
Tried the latest CVS version (php5-200407261630). And applied the session patch which wasn't included yet. It seemed like it was running okay for about 15 seconds. Then I kept getting more segfaults. It's back to the old refcount issue. Having all the bugs at once makes it hard to isolate which patch fixes what, if anything at all.
i'm lovin' it.
Print This Post