views:

144

answers:

0

We are looking at redoing some web service applications (currently in prototype phase) from WCF/C# to a C++ cross platform web service framework. So, I'm looking at Axis2/C or WSO2 WSF/C++ as possible frameworks. I'd really like to port the functionality already written in the WCF service to the other service frameworks.

Here's the functionality:

  • Web GET calls return JSON - supported by Axis2/Java (not sure about C/C++ versions yet)
  • Can also return arbitrary content (like generated images or pages).

In WCF, you can return JSON by decorating the service operation like this:

[OperationContract]
[WebGet(UriTemplate = "/calltimings", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
TimingInfo[] CallTimings();

where TimingInfo is a simple data contract that serializes to JSON. I can find how to do the same in Axis2 (Java version anyways).

The other call my webservice supports is:

[OperationContract]
[WebGet(UriTemplate = "/ping.htm")]
Stream PingHTML();

where the html page is generated dynamically. There are other similar calls that return a Stream that contains the contents of generated images. The WCF framework magically takes the Stream and puts the contents directly into the HTTP response body. That is great for images, because I can write web client code like this:

<img id="viewportX" src="http://www.myservice.com/getimage?rotation=93"/&gt;

So, my question is: How can I write an Axis2/C service operation that will return image content directly to the caller?

How can I write this in the web client?

<img id="viewportX" src="http://www.myservice.com/axis2/some_service/getimage?rotation=93"/&gt;

Can I?