Tuesday, September 30, 2008

Rendering a html file which is in svn as text/html

I'm sure people have come across this issue before. The solution for it is simple though.

If you were to browse to a html file in svn it would be rendered as text/plain in the browser, but if you needed it to be rendered as text/html you need to do the following.
svn propset svn:mime-type text/html
You could use the above command to set any mime-type on a file thats in svn.

Monday, September 29, 2008

Apache Axis2 Changing the Content-type of the Response

There are a couple of mechanisms that can be used to change the content-type of the response in Apache Axis2. They are,
  • Using HTTP Content Negotiation. Please refer HTTP Content Negotiation with Apache Axis2 for details.
  • Changing the content-type of the response explicitly by setting it to the response message context as follows,
      MessageContext messageContext = MessageContext.getCurrentMessageContext();
OperationContext operationContext = messageContext.getOperationContext();
MessageContext outMessageContext = operationContext.getMessageContext(
// responseFormat is the content type of the outgoing message
outMessageContext.setProperty(Constants.Configuration.MESSAGE_TYPE, responseFormat);

Sunday, September 28, 2008

Fernando Alonso wins Inaugural Singapore Grand Prix

Fernando Alonso won Inaugural Singapore Grand Prix a few moments ago. In the process he became the first man to win a night race. Singapore was the latest circuit to hold a Grand Pix and it was the first time that a race was held in the night. I'm not a Fomula One (like Channa is) fan but I did watch this race cause it was one of a kind. The race track was lit up by around 1500 lights powered by 24 generators with 110 KM of cable connecting them together. It was also said that the race track is lit so that no two adjacent lights could go off. Pretty impressive and on top of that (Literally over the race track) a grand stand that could hold 38,000 spectators.

It was a bad race for Kimi Raikkonen cause he crashed out with just four laps to go. He was in fourth place at the moment and was in position to pick up championship points.

Whats more Massa of the Ferrari team pulled out of the pit stop (It wasn't his fault because the light was green when he pulled off) with his fuel horse still connected. Not a good race for a few of the top guns.

Training on Apache Synapse & WSO2 ESB

Last week I had a great opportunity to attend a two day training on Apache Synapse and the WSO2 ESB (Enterprise Service Bus). This was an internal training conducted by Asankha. The first day of the training focused on what the WSO2 ESB is and how users would use it. He also took us through all the in built mediators of the ESB. The second day of the training focused on how the ESB Works. For me this was the most interesting part of the training.

Transports are a major part of an ESB. Asankha took us into detail of each transport, the most interesting was the JMS transport and the NHTTP Transport (Non Blocking HTTP Transport). I had played around with the JMS Transport in the mashup server. I even wrote an article on how the JMS Transport can b used in the mashup server. Knowing how to use something is different from knowing how it works.

Next in line was the most anticipated NHTTP Transport. This was the major component of the ESB and all its great performance was due to it. It was s pleasure to get to know how it works.

Prior to this i had used the WSO2 ESB on a customer project and getting to know how it works was really intriguing.

Friday, September 26, 2008

RESTful Web Services with Apache Axis2

RESTful Web Services with Apache Axis2 is powered by the WSDL 2.0 HTTPBinding, hence as of now (1.4.1 release of Axis2) users need to deploy there services using WSDL 2.0 to write truly RESTfull services in Axis2. I agree that there aren't too many people who are familiar with WSDL 2.0. Therefore I put together an article that helps you through the process of taking your Java code, generating a WSDL 2.0 from it and hand editing it to suit your needs. The article "RESTful Web Services with Apache Axis2" is now available on the WSO2 oxygen tank.

I plan on making it simpler to author RESTfull services in Axis2 in future.

Axis2 & Rampart - Access Username used for Authentication in a Web Service

Nandana in his blog post has explained how you could do this (Axis2 & Rampart - Access Username used for Authentication in a Web Service) with the latest Rampart code. But if you are using Rampart 1.4 that method will not work. Those users can use the following method,

MessageContext msgCtx = MessageContext.getCurrentMessageContext();

Vector results = (Vector) msgCtx

if (results != null) {

WSHandlerResult result = (WSHandlerResult) results.get(0);
WSSecurityEngineResult wsSecurityEngineResult =
(WSSecurityEngineResult) result.getResults().get(1);
String username =
((Principal) wsSecurityEngineResult.get(WSSecurityEngineResult.TAG_PRINCIPAL))

Thursday, September 25, 2008

Enabling JSON in WSO2 WSAS

In order to enable JSON support in WSO2 WSAS you will need to follow the following steps.
  1. Drop the axis2-json-1.4.1.jar (The version may change according to the WSAS version in use) in to the WSAS lib directory. You could download axis2-json-1.4.1.jar here.
  2. Drop the jettison-1.0.1.jar in to the WSAS lib directory. You could get it from here.
  3. Configure the axis2.xml in WSAS which can be found in the conf directory as described in "Enabling JSON in Apache Axis2".

Enabling JSON in Apache Axis2

Apache Axis2 can handle several message formats. JSON is just one of them. Axis2 supports two notations of JSON, they are known as mapped and Badgerfish. Namespaces are not handled in the mapped notation while the Badgerfish notations supports it.

The default Axis2 installation has all the binaries needed to process JSON messages but you need to enable it in order to use JSON. This can be done by adding the following sections to your axis2.xml.

Add the following section to the messageFormatters section in the axis2.xml,

<messageFormatter contentType="application/json"


<messageFormatter contentType="application/json/badgerfish"


<messageFormatter contentType="text/javascript"


And the following to the messageBuilders section of the axis2.xml

<messageBuilder contentType="application/json"


<messageBuilder contentType="application/json/badgerfish"


<messageBuilder contentType="text/javascript"


Now you are all set to invoke services as well as respond using JSON. You would notice that the notation of JSON used depends on the content-type of the message.

Deploying WSO2 Registry on JBoss 4.0.5

The WSO2 Registry comes as a war distribution which can be deployed in a servlet container. If you are interested in deploying the WSO2 Registry on JBoss 4.0.5 this blog post by Bruno will help.

HTTP Content Negotiation with Apache Axis2

Since the 1.3 release of Axis2, it supports HTTP Content Negotiation. It is not turned on by default but can be done so by adding the following parameter to your axis2.xml.

<parameter name="httpContentNegotiation">true</parameter>

Axis2 does not honor the content-type text/xml when its in the Accept Header. This is because the content-type text/xml is primarily used for SOAP 1.1 but when a request is sent via the browser it has the Accept header as "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 ". If we were to honor text/xml this would result in a SOAP 1.1 response. Not too good for a REST scenario ha! This is the result of the same content-type (text/xml) been used for two message formats (SOAP 1.1 and POX).

Now lets get back to HTTP Content Negotiation with Apache Axis2. Performing a GET request on the version service would result in the following request and response. You could capture them by using TCPMonitor.

Now try editing the Accept header to "application/json/badgerfish". You should have enabled JSON support for this to work. This would result in,

A blog post on how to enable JSON on Axis2 will follow. This configuration can be used to enable HTTP Content Negotiation on WSO2 WSAS as well as the Mashup Server. It should work with Synapse and the WSO2 ESB too but I haven't checked it.

Wednesday, September 24, 2008

Mashup Server as a Teaching Tool

I've been involved in quite a few trainings in the recent past. Both on Axis2 as well as the Mashup Server. The newest on the list was a "Introduction to WSDL 2.0" training that I conducted yesterday. One of the cool tools that I have used in all these trainings is the Mashup Server. The Mashup Server makes it amazingly simple to to create services in a matter of minutes, whats more there is a bunch of resources thats auto-generate for each service.

For e.g I used my RESTDemo mashup extensively to describe how WSDL 2.0 enables REST.

Note : The RESTDemo Mashup does not cover all capabilities of WSDL 2.0. I intend to do a comprehensive write up of this soon.

One might wonder how the Mashup Server helps teach a person Axis2? Well to be frank the Mashup Server is a highly customized version of Axis2. We've used quite a few extension points in Axis2 to make the Mashup Server what it is. Hence its a great case study for the customizability of Axis2.

Saturday, September 20, 2008

WSO2 Data Services 1.0 Released!

The title says it all, after months of hard work the 1.0 version of the WSO2 Data Services Solution is out. This version of Data Services is based on carbon, which is based on OSGI. There were quite a lot of challenges that the Data Services team had to undergo in order to pull of this release.

Some key features of this release are,
  • Built-in Connection pooling support
  • Aggregate data from multiple data sources
  • Support for exposing Stored procedures & functions
  • Built-in caching to enhance performance
  • Throttling to ensure that your database is never overloaded
  • Secured access to data
  • Reliable delivery of messages
It also come with an eclipse IDE plugin.

For those who are not familiar with WSO2 Data Services is, it is a way to expose data locked up in Data Bases, Excel files or CSV files as Web Services in a matter of minutes. And it requires zero code (You could either use the wizard that comes with it or simple use your favorite editor to write your configuration).

Sumedha's blog has quite a few tips on Data Services. From doing basic stuff to more advanced scenarios.

As with all products at WSO2 the Data Services Solution is shipped under the Apache License. Download it and try it out.

Thursday, September 18, 2008

Web Services Framework for Jython Released!

WSF/Jython (Web Services Framework for Jython) is the latest addition to the impressive SOA stack at WSO2. It provides an amazingly simple approach to write web services as well as consume web services using Jython. As with all other products at WSO2, it is released under the Apache License hence you can download it and give it a try.

There are two packages that comes with this release, the server side and the client side.

Client Side Features

  • Support for invoking Web Services in a simple clean manner

  • Ability to use WS-Addressing when invoking services

  • Ability to invoke services which require WS-Security

  • Ability to send binary attachments using MTOM

Server side Features

  • Support for exposing services written in Jython

  • DataBinding support using a simple annotation mechanism

  • Automated WSDL generation

  • Ability to expose all enterprise features of Axis2 to services written in Jython
Here is one of the simplest services you could write. It contains a add method which would add two integers and return the result as an integer. The annotations are used to describe the actual data types that flow in and out of a function.

#@annotate("returns=int", "operationName=add", var1="integer", var2="integer")
def add(var1,var2):
return var1+var2

You could refer the article Deploying Python Services for more details.

Now lets see how easy it is to write a client for the service that we just wrote.

from org.wso2.wsf.jython.client import WSClient
from org.wso2.wsf.jython.client import WSFault
from org.wso2.wsf.jython.client import WSMessage

req_payload_string = "12"
END_POINT = "http://localhost:8080/axis2/services/simpleService"

client = WSClient({ "to" : END_POINT}, "")
req_message = WSMessage(req_payload_string, {})
print " Sending OM : " , req_payload_string
res_message = client.request(req_message)
print " Response Message: " , res_message

except WSFault, e:

You could execute this client by simple running the "wsfjython" shell script as follows,

sh wsfjython.sh /opt/software/wsf-jython-client-1.0-alpla/samples/myClient.py

For more details on writing clients and usage of advanced features please refer the article "Invoking Enterprise Web Services using Jython".

WSF/PHP - Use Cases Discussed

Katie having a discussion with Shankar (Lead developer of WSF/PHP) on what WSF/PHP (Web Services Framework for PHP) can be used for at ZendCon 2008.

WSF/PHP 2.0 was released just a few days ago.

Wednesday, September 17, 2008

Expose and Invoke Mashups over JMS

My article on Exposing and Invoking mashups using SOAP/POX over JMS with the WSO2 Mashup Server has been published on the WSO2 developers portal for SOA. It talks about how you could invoke mashups running on a WSO2 Mashup server over JMS and also how you could send JMS messages using a Mashup running on the server. You would me amazed to see how easy it is. The article contains sample code which help you get going in minutes.

JMS plays an important part in most enterprises and this open the door for enterprise mashups using the Mashup Server.

Get Twitter Friends Time Line Using a Mashup

Milinda has posted how to Get Your Twitter Friends Time Line Using libcurl. I thought of publishing a alternative mechanism to doing it. How about getting your twitter friends time line using the WSO2 Mashup Server? Well is pretty simple and straight forward. Here is the code (Just a few lines of code),

function getTwitterFriendsTimeline(){
var request = new WSRequest();
request.open("GET","http://twitter.com/statuses/friends_timeline.xml?count=5", false, "username","password");
return request.responseE4X;

Pretty simple ha! If you wanted you could have published this on mooshup and have it run for you 24*7 for you. Of course you might want to do something with this data to make it a useful mashup.

Apache Axis2 java2wsdl Usage - Graphical Tool

It seems that quite a few people are having trouble using the java2wsdl tool that comes with Axis2. Using a command line tool can be tricky for some users... but wait there is a graphical tool for this too. WSO2 WSAS (Web Services Application Server) has a graphical tool that wraps the java2wsdl utility in Axis2. You can either try it out by downloading WSAS (WSO2 WSAS is open source and available under Apache License v2.0) or if you are in a hurry you could try the java2wsdl graphical tool online. This tool takes you through a wizard like approach and is much easier to use (The tool hosted online is based on WSO2 WSAS 2.3 which is in turn based on Axis2 1.3 with a few bug fixes). You could fine a lot more tools that could help you at http://wso2.org/tools.

For the geeks who do not want to use the graphical tool this is how the command line utility can be used. Simple executing the java2wsdl script without any arguments would show you its usage,

keith@keith:/opt/axis2-1.4.1/bin$ sh java2wsdl.sh
Using AXIS2_HOME: /opt/axis2-1.4.1
Using JAVA_HOME: /opt/software/java/jdk1.5.0_06
Usage: java2wsdl [options] -cn <fully qualified class name>

where [options] include:
-o <output location> output directory
-of <output file name> output file name for the WSDL
-sn <service name> service name
-l <soap address> address of the port for the WSDL
-cp <class path uri> list of classpath entries - (urls)
-tn <target namespace> target namespace for service
-tp <target namespace prefix> target namespace prefix for service
-stn <schema target namespace> target namespace for schema
-stp <schema target namespace prefix> target namespace prefix for schema
-st <binding style> style for the WSDL
-u <binding use> use for the WSDL
-nsg <class name> fully qualified name of a class that implements NamespaceGenerator
-sg <class name> fully qualified name of a class that implements SchemaGenerator
-p2n [<java package>,<namespace] [<java package>,<namespace]...
java package to namespace mapping for argument and return types
-p2n [all, <namespace>] to assign all types to a single namespace
-efd <qualified/unqualified> setting for elementFormDefault (defaults to qualified)
-afd <qualified/unqualified> setting for attributeFormDefault (defaults to qualified)
-xc class1 -xc class2... extra class(es) for which schematype must be generated.
-wv <1.1/2.0> wsdl version - defaults to 1.1 if not specified
-dlb generate schemas conforming to doc/lit/bare style

Most often that not you wont be using most of these options. Assuming that your,
output directory is /home/keith/projects/axis2_rest/resources/
output Filename is StudentService.wsdl
service name is StudentService
classes are in the directory /home/keith/projects/axis2_rest/classes
service implementation class is prg.apache.axis2.StudentService
you need WSDL 2.0

your usage of java2wsdl would be,

sh java2wsdl.sh -wv 2.0 -o /home/keith/projects/axis2_rest/resources/ -of StudentService.wsdl -sn StudentService -cp /home/keith/projects/axis2_rest/classes/ -cn org.apache.axis2.StudentService

Tuesday, September 16, 2008

REST and WSDL 2.0 Discussion continues

In response to my blog post on using WSDL 2.0 to describe RESTfull services and Sanjiva's challenge Stefan has put forward 5 questions for me. Here are the answers to them.

Question: How does one one describe representation formats other than XML?
Answer: This can be done using the whttp:inputSerialization (for input messages), whttp:outputSerialization (for outgoing messages) and whttp:faultSerialization (for outgoing faults). The WSDL 2.0 Adjuncts spec defines three types of serializations. They are application/x-www-form-urlencoded, application/xml and multipart/form-data. Axis2 supports all three of these as well as JSON messages (This is how you can send JSON messages using the Mashup Server). At WSO2 we are considering doing a JSON binding for WSDL. If we had that in place even this could be described in a standard manner.

Question: How is content negotiation supported?
Answer: WSDL cannot describe this (neither do I expect it to), but we do have content negotiation support in Axis2. Due to some practical limitations we had to make it an optional feature. This can be made available by adding the following parameter to the axis2.xml.

<parameter name="httpContentNegotiation">true</parameter>

Question: How does one describe whether a URI parameter is a query parameter, path element, or matrix parameter?
Answer: There are a few properties and defaulting rules that help you achieve this. As my example shows parameters can me made to go in the path or query section using templates. An example template for sending the parameter "name" in the path segment would be "student/{name}" while sending a parameter as a query parameter would be "student?name={name}". This section in the adjuncts spec give a brief idea as to where the parameters not cited would appear. If application/x-www-form-urlencoded serialization is used on a GET all parameters not cited in the template would go in as query parameters. There is a additional property in WSDL 2.0 that helps you control this too. If you specify whttp:ignoreUncited="true" then all uncited parameters will be dropped.

What do you really mean by matrix parameters?

Question: Is there a way to describe response codes?
Answer: WSDL 2.0 does not allow you to specify the http response code of a outgoing message. Too bad we missed this (I wonder whether the working group had discussed this issue though). I guess this is the one thing that WSDL 2.0 missed. Hence I opened a issue against the spec. But WSDL 2.0 allows you to set http codes on fault messages. For e.g on a fault you could say whttp:code="402".

Question: What about describing hypermedia? :-)
Answer: In my example you would have noticed that I actually return a set of links to where the actual resource exist when invoking some operations. For e.g getAllCustomers would return links to the actual customers. I agree that there is something missing in here, a way to describe that accessing this link returned, would fetch you the customers details (Probably an annotation in the schema could describe this).

Stefan had mentioned the following in his post

"One of the interesting aspects is the try out page, which is generated from the WSDL. Essentially this means that metadata is used to generate the self-descriptive form; somewhat backwards from a REST perspective, but understandable given that the goal was to have an external description in the first place."

Yes the WSDL captures all the metadata of your service. Don't you think that there is a definite advantage in having a standard description for your service? This would enable users to build tools that would make life easy when accessing such services. The tryit is an good example of this. You could even build a UI for a service using a generated JavaScript stub. The UpgradeChecker sample on mooshup is a good example for this.

Its good to have a constructive discussion around REST, SOAP and WSDL rather than try to proclaim that one of them is the way to go and the other does not have a place.

Monday, September 15, 2008

Sending IM Messages via Yahoo using the Mashup Server

[Note: also published on the Mooshup.com blog.]

If you try to send IM messages using a yahoo account in the WSO2 Mashup Server you may encounter the following error.

Fault: Cannot find yahoo library in the class path. Please make sure its in the classpath.

The reason for this could either of the following,
  • The yahoo Library in not in your classpath - Download the latest version from YMSG
  • You have the yahoo library in your classpath but its an old version. You need to have the latest version in your classpath to get this working.
Now that you have the latest version of the Yahoo messaging library in your classpath its time to test it out.
Here is a simple client for sending a IM message via yahoo,

function IMExample(){
var im = new IM("yahoo");
im.sendMessage("keithgodwinchapman","Hi, This was sent from the WSO2 Mashup Server!");

For more details on sending IM messages using the WSO2 Mashup Server please refer the "Sending Instant Messages via Mashup Server" article.

You may have noticed that this sample is very similar to Sending MSN messages using the Mashup Server.
It is indeed the only difference is the argument you pass into the constructor of the IM host object. Have fun sending IM's using the WSO2 Mashup Server!

RESTfull Mashup with WSDL 2.0 - WSO2 Mashup Server

I was looking around for REST stuff related to Axis2 and stumbled upon one of Stefan Tilkov’s blog post (An old one at that). In that post Stefan had asked somebody to show a WSDL 2.0 document that describes this RESTfull scenario.

Too bad I didn't come across this back then, but as the saying goes better late than never. WSDL 2.0 can describe this scenario easily and I thought of writing a WSDL 2.0 document for this scenario (I've made one change to the URLS used in the scenario, instead of customer/{id}/orders I've used customerorders/{id}. This is not due to a limitation in WSDL 2.0 but rather the implementation of Axis2).

I put all these details together and built a little Mashup (which I named RESTDemo) that runs on the WSO2 Mashup Server. Of course the WSO2 Mashup Server has the ability to build RESTfull Mashups. In order to make it accessible to others I've uploaded it to Mooshup.com our community site.

Note : I have made some assumptions on how an Order and a Customer will be described. My assumptions is that an Order is described by an id (String), customerID (String), details (String), amount (Double), items (String array). A customer will be described as id (String), name (String), address (String), email (String).

The main objective of putting this Mashup together was to demonstrate that this RESTfull scenario can be described using WSDL 2.0. The WSDL 2.0 for this mashup can be accessed from the Mashup page, you could choose either the annotated view or the raw view.

The all important section in the WSDL is the HTTPBinding , cause this is where all the information for accessing this service via REST lies. Ideally I would have loved to make the content-type (whttp:inputSerialization in WSDL 2.0 terms) of a few of the operations application/x-www-form-urlencoded (WSDL 2.0 defaults it to application/xml) . But unfortunately as of now the Mashup Server does not offer a mechanism to do this. I've already opened a JIRA so that this could be added.

You might also want to try out our RESTfull mashup. Simply goto its tryit page in order to try it out (The tryit page allows you to test your mashup and a drop down at the top allows users to select the endpoint they want to access, in our case we may prefer to choose the HTTPEndpoint cause this is all about REST). Now this is where the benefit of a standard description (WSDL 2.0) for our RESTfull mashup kicks in. The tryit page is auto generated off the WSDL 2.0 doc (It has all the information as to how this mashup can be accessed, let it be SOAP 1.1, SOAP 1.2 or REST). The tryit page invokes the service using a auto generated JavaScript Stub.

Let me now explain as to why I had to change the URL mapping for get all customer orders. Axis2 (Which is what the WSO2 Mashup Server is built on) dispatches to the correct operation (when REST is used) using the http method and the URL of the request (The service is always found using the request URL). Now when we try to figure out the operation the request is headed to we basically do some pattern matching, and thats done against the first constant part we get off the httpLocation. In the scenario given it allows a GET on customer/{id}/orders as well as customer/{id}. Now if I used these two templates as it is, there would have been dispatching issues, hence I decided to change the second template.

This has become quite a long blog post. If you are interested in knowing how WSDL 2.0 can be used to describe RESTfull services stay tuned to my blog. I plan to write more on this topic in the time to come. Also there is a RESTfull services on Axis2 tutorial which is just around the corner.

Note : Mooshup is running the 1.5.1 version of the WSO2 Mashup Server (released before Axis2 1.4.1). There fore its REST URLs are of the format http://mooshup.com/services/keith/RESTDemo.HTTPEndpoint/customer/123, in the next version which will be based on Axis2 1.4.1 the URLs of the form http://mooshup.com/services/keith/RESTDemo/customer/123 would also work.

Sunday, September 14, 2008

XML Schema - Import or Include?

I'm sure people who work with XML Schema or WSDL for that matter have hit this issue at some point. The dilemma weather to use Include or Import? I came across this article that helps solve this problem. Hope that it will come in handy for you too.

Saturday, September 13, 2008

Basket Ball @ WSO2 in Full Swing

Work while you work,
Play while you play,
This is the way
To be happy each day.

Thats exactly what we do at WSO2, although we do play a bit while we work as well ;).

We are having a Basket Ball tournament at WSO2 these days. The tournament is in full swing as we draw near to the business end of the tournament, the Finals and Third place play offs. Quite a few of our guys (Tyrell, Ruwan Janapriya, Saliya) have been busy taking photos as well.

As with any tournament we've had our fair share of Injuries too. Sameera - a twisted ankle, Chanaka - a cracked lip, Sanjaya Ratnaweera - a dislocated wrist and the latest victim Sumedha with a sprained ankle. Oh and I almost missed poor Devaka who is suffering from a Sore finger and a sore toe ;).

I'm sure this first aid tips that Sumedha had got from his doctor would come in handy in the coming weeks.

Attachments - MTOM, SWA and Base64Binary Compared

Sending Attachments in Web Services is a common use case and there are various ways in which this objective could be achieved. Sending the Attachments as MTOM (SOAP Message Transmission Optimization Mechanism), SWA (SOAP with Attachments), or Base64Binary are some of your options.

Here is a simple comparison between these 3 options.
  • base64Binary sends the attachments as base64 inline in the SOAP message. i.e. The Attachment in embedded in the SOAP Message. Bloats the message by 33%.
  • SWA sends the Attachment outside the SOAP message (The SOAP message contains a reference to the attachment). But the SOAP infoset does not contain the attachment
  • MTOM Provides the best of both world. The Attachment is sent outside the SOAP message with a reference to it but the attachment appears as if it is embedded in the SOAP message (The SOAP infoset contains the attachment)
Due to the fact that attachments sent using MTOM appear as it the attachment is part of the SOAP message it allows you to use other WS-* QOS (Quality of Service) attributes. For e.g MTOM messages can be signed and encrypted using WS-Security. Thus this provides a mechanism to send Secured Attachments without the need for additional specs.

Axis2 as well as (WSO2 WSAS) supports all three of the above mechanisms. In a later post I will describe how each of the above can be used and how the actual wire messages look.

WSF/PHP 2.0 Released!

The WSF/PHP team has released the 2.0 version of WSF/PHP (Web Services Framework for PHP). This release promises a bunch of new and cool features. Some of the more prominent ones are,
Please refer the release note for the full list of features. You can also visit the PHP demo site for a feel of what WSF/PHP has to offer. It contains Code Samples, demos and tutorials.

You can also download the Stock Trader 2.0 demo which shows how WSO2 WSF/PHP, WSO2 WSF/Ruby, WSO2 WSF/Spring, WSO2 WSF/Perl, WSO2 WSF/Python and WSO2 WSAS inteoperates with the Microsoft .NET platform.

Thursday, September 11, 2008

Interactive Defence Map of Sri Lanka

Its no secret that there is a war going on in the northern part of Sri Lanka. This interactive Defence Map of Sri Lanka shows the recent activity that has been recorded from the war front. It even goes to show how the LTTE light Air Craft was attacked over Mullaittiuvu.

Axis2 java2wsdl - Never Use An Interface

Well this is not an issue with Axis2 but rather the way Java treats an Interface. There has been numerous occasions when users have been bugged by this (Parameter names appearing as param0, param1 in the WSDL instead of the actual parameter names). This could happen because of two reasons,
  1. Your service class was compiled without the debug option been turned on. Please refer How to make WSDL display actual parameter names? in order to see how this issue can be avoided.
  2. You used an Interface as the service class name when using java2wsdl. For this I'm sorry - there is no solution. Even if you had turned on the debug option when compiling the interface, java would not push down the parameter names into the compiled code (After all, its an interface and it just defines the contract and the actual class thats implementing this interface may have called those parameters something else)
So the bottom line is this. Always avoid using an Interface as the service class when using java2wsdl and when using a class, please make sure that its compiled with the debug option turned on.

Tuesday, September 9, 2008

Two Years at WSO2

The beginning of this month marked the completion of my second year at WSO2. Its been a great two years at that. Initially I was involved in helping improve the Axis2 IDEA plugging for the 1.1 release. This was my first steps with Axis2 and that helped me gain the committership for Axis2 later that year. The Axis2 1.1 release was a very important one and one of my batch mates Thilina was the release manager.

My involvement with Axis2 was propelled by the fact that I got the opportunity to attend the WSDL 2.0 interop in France which was held from the 14th to the 18th of November that year.

Members at the WSDL 2.0 interop.

This was just 2 months after I had joined WSO2. I went to the interop along with Chinthaka. We had the chance to pay a visit to the Eiffel tower as well as the world famous Louvre museum.
At Eiffel

At Louvre

By the time we went to the interop I was not too familiar with the internals of Axis2, I was just providing a helping hand to Chinthaka. But that trip threw me into the deep end of Axis2. The time frame given to the working group was to end on the 31st of December and they needed two independent implementations to pull the spec through. We were one of the implementations and we had more work to do, especially on the http binding. The other implementation was from canon and they were not interested in implementing the http binding (They did support us by implementing a subset of the http binding though) so we had the added pressure and to make matters worse (or you could look at it as provide me more opportunity ) Chinthaka was leaving for grad school early December. So I was charged with the responsibility of implementing these stuff. That was how I got into the internals of Axis2.

Although I worked on Axis2 full time at the start later on I moved on to work on the WSO2 Mashup Server. Even though I've been working on the Mashup Server ever since, I've always been in close proximity with Axis2. That has been for 2 main reasons. One is that I love working on Axis2 and the second been the fact that Axis2 is the foundation of most of the products at WSO2 including the Mashup Server.

Monday, September 8, 2008

Axis2 Training in Phoenix

Last week I was in the scorching heat of phoenix in order to conduct a 4 day training course on Axis2 along with Glen. This was the first time I had visited Phoenix. The temperature on Sunday (the 25th) was 43 Centigrades (we Sri Lankans are used to the metric unit system) and it was the first time I had experienced such a temperature. The first thing I noticed when I got out of the Sky Harbor airport in Phoenix was the scorching heat. The air smelt like something was getting roasted :-) , yes thats how hot Phoenix was.

My flight into Phoenix wasn't the most straight forward. It was Colombo, Narita, Dallas, Phoenix. Interestingly 5 of us (Manjula, Nandana, Dimuthu, Isuru and myself) were on the same flight to Narita and from there we went in 3 different directions. Manjula and Nandana were on there way to Seatle while Dimuthu and Isuru were headed to San Francisco and I was headed to Dallas.

The training itself was interesting. It was my first 4 day course. I had conducted tutorials and online training on Axis2 prior to this though and Axis2 was nothing new to me. Its amazing how easy it is to teach something that you've been playing with and developing for so long. Whats more I was conducting the training along with Glen who is a pioneer when it comes to Axis (both Axis and Axis2).
My flight back home was even worse that my flight into Phoenix. It was Phoenix, Dallas, Narita, Singapore, Colombo with a total travel time of close to 44 hours. It was an interesting co-incidence that all of us met in Narita on our way back as well. The others went to Singapore on a separate flight while my flight to Singapore was 2 hours after there's. And from Singapore to Colombo we were on the same flight :-)

Thursday, September 4, 2008

Invoking Mashups using JSON

Mashups running on the WSO2 Mashup Server can be invoked in using various message formats. They are SOAP 1.1, SOAP 1.2, POX (Plain Old XML), REST, JSON, SOAP/POX over JMS, SOAP/POX over SMTP.

Here is how you can use JSON to invoke a simple Mashup. In this example I will be invoking the RESTSample running on mooshup.com. This simple sample sends the payload as JSON and receives the response as JSON as well.

// Providing optional annotations
invokePOSTWeather.inputTypes={"city" : "string", "weatherDetails" : "string"};
function invokePOSTWeather(city, weatherDetails){
var request = new WSRequest();
var options = new Array();
// Instracts the server that my request needs to be formatted as JSON
options.HTTPInputSerialization = "application/json/badgerfish";
var payload = <POSTWeather><city>{city}</city><weatherDetails>{weatherDetails}
var result;
try {
request.open(options,"http://mooshup.com/services/samples/RESTSample/", false);
result = request.responseE4X;
} catch (e) {
result = e.toString();
return result

If you were to use TCPMonitor to trace the messages you will be able to see the messages sent and received by the Server.

Here is the request sent out by this Mashup


And the response it received


Note : There are three main ways that you can get the response from WSRequest. There are response.responseText, response.responseXML and response.responseE4X. If you were to use these variants when the response if JSON they will act as follows,

response.responseText - Would return the JSON string as the response
response.responseXML - Would return the XML representation of the JSON string
response.responseE4X - Would return the E4X representation of the JSON string

Wednesday, September 3, 2008

Sending IM messages via MSN using the WSO2 Mashup Server

[Note: also published on the Mooshup.com blog.]

If you try to send IM messages using a windows live account you may encounter the error reported in the JIRA MASHUP-1087. The reason for this is that the library we use to send IM messages via MSN (jml) is outdated. A newer version of this library was released on the 5th of August 2008 and is available here.

In order to get this working you need to download the 1.0b3 version of jml and drop it into the lib/patches folder of the WSO2 Mashup Server and restart it.

Here is a simple client for sending a IM message via MSN,

function IMExample(){
var im = new IM("msn");
im.sendMessage("keithgchapman@hotmail.com","Hi, This was sent from the WSO2 Mashup Server!");

For more details on sending IM messages using the WSO2 Mashup Server please refer the "Sending Instant Messages via Mashup Server" article.

Tuesday, September 2, 2008

Apache Axis2 1.4.1 Released

Yes the subject says it all. The main reason for putting out a 1.4.1 release a was security vulnerability present in Apache Axis2 1.4 policy processing. The 1.4.1 release fixes this security issue plus a few critical issues that were present in the 1.4 release.

Nandana who primarily works on Axis2 and Rampart noticed this security vulnerability and sent a note to the Axis2 list who decided to push for a 1.4.1. Of course Nandana volunteered to be the release Manager ;).

This exemplifies the beauty of Open Source. After all the Open Source mantra is "Release early, release often".