Tuesday 21 February 2012

Serving the Mule Tools XSD using the Apache Rewrite Module and PHP

After I created the NamespaceHandler and XSD for the Integration Cocktail Mule Tools module, I wanted to make the XSD available at the URL http://www.integrationcocktail.org/schema/mule/tools/3.2/mule-tools.xsd so that users of the module will have code completion using any half decent XML editor. I bought the domain and was going to use a simple LAMP server to provide the XSD. It was straightforward enough if I wanted to simply put the XSD file, however I know myself, I will forget to update the XSD file after I will do any form of updates to the file. So why not provide the schema directly from the git repository? So, after years not touching any form of PHP I was going to hack a bit with it.

First I added a .htaccess file to rewrite all requests for .xsd files which do not exist to my php script:



After that all I had to do is create a simple script to proxy. I used PHP cURL library to do the requests and voila, simple enough:



Anybody out there who is creating custom mule modules and as they should, to encourage use, creates a custom namespace, please, do make the XSD available for your fellow developers so that you do not have to stay adding it to the IDE.

No comments:

Post a Comment