Tuesday, October 21, 2008

How to use Attachment Caching with WSF/PHP

WSF/PHP 2.0.0 has the support for caching attachments ( writing to a file ). This effectively reduces the amount of memory used when sending and receiving attachments and its specially useful, if your application requires to send or receiving a very large file in the scale of megabytes.

WSF/PHP adds two php.ini entries in order to allow attachment caching.

1. wsf.attachment_cache_dir

2.wsf.enable_attachment_caching

wsf.attachment_cache dir is the location where the received attachments will be saved.

wsf.enable_attachment_caching option enables attachment caching.

By default, attachment caching can be done only for attachments larger than 1 MB.

Lets see a code sample on how to use this. This is a simple php service, which reads a binary file and send it to the client as an MTOM attachment.

ini_set("wsf.enable_attachment_caching", 1);
ini_set("wsf.attachment_cache_dir","E:\\");

function sendAttachment($msg)
{
$responsePayloadString = << http://php.axis2.org/samples/mtom">
test.jpg
http://www.w3.org/2004/06/xmlmime">
http://www.w3.org/2004/08/xop/include" href="cid:myid1">


XML;

$responseMessage = new WSMessage($responsePayloadString,
array( "attachments" => array("myid1" => "../resources/large_image.jpg")));
return $responseMessage;
}

$operations = array("download" => "sendAttachment");

$service = new WSService(array("operations" => $operations, "useMTOM" => TRUE));

$service->reply();

?>

Now in above code, I have highlighted the important code pieces.

1. The php ini settings at the top of the code where the attachment_cache_dir is set and attachment caching is enabled.

ini_set("wsf.enable_attachment_caching", 1);
ini_set("wsf.attachment_cache_dir","E:\\");

2. Setting of a fake content id to which the actual attachment is assigned.

href="cid:myid1"

3. Instead of setting binary attachment as an string in the attachment array, we should set the actual path to the file.

array("myid1" => "../resources/large_image.jpg")

Thats all you need to do to get attachment caching working. The same technique can be used for the client as well. It will be consuming lot less amount of memory.


http://phpwebservices.blogspot.com/2008/10/how-to-use-attachment-caching-with.html

Friday, October 17, 2008

What's new with iGoogle?

iGoogle?

I'm an iGoogle addict. I check my news, email, stocks, feeds and weather there and sometimes even manage to squeeze in a game or two during the day. Having everything in one place is super convenient, but I often wish I could deal with all my stuff without having to leave my iGoogle page. With today's release, I can. We've rolled out an updated design for iGoogle to all U.S. users, which includes full canvas views for gadget and support for full feed reading.

Not all of our gadgets have canvas views yet, but here are some of the best:
  • News - New gadgets from The New York Times, The Wall Street Journal and The Washington Post give me full-page views of what's new in the world. Nice.
  • Games - The Sudoku gadget lets me play thousands of full-page Sudoku puzzles without squinting at 6-point type. The GoComics gadget gives me my fix of Garfield and Doonesbury and lets me choose from all of their other comics. I've also spent many coffee breaks browsing through videos from YouTube and CurrentTV.
  • Entertainment - I've configured the TV Guide gadget to my zip code and just used it today to figure out when the newest episode of The Office is playing. Flixster's movies gadget lets me access trailers, ratings, and theater information for any movie. I also use the iLike gadget to browse news, concerts, and free MP3s from my favorite musicians.
  • Google stuff - The new Gmail gadget lets me read my full email and perform simple actions like send or reply to emails without leaving iGoogle. Last but not least, a gadget that I authored and use every day is for Google Finance, which provides full-screen finance charts and news of the stocks in my portfolio.
Here's a full list of our highlighted canvas view gadgets.

We've also replaced the tabs at the top with a left navigation that allows for access to any gadget with one click. We're very excited about these changes because it makes iGoogle a more useful homepage and a better platform for developers. And this is just the beginning: Expect to see more canvas gadgets created by developers and more new features on iGoogle soon. Not in the U.S.? Don't worry. We'll also be rolling out this updated version in other countries very soon.