Oxid and AMF protocol communication/web services

Hi all,

I’m currently investigating the best way to integrate Oxid with Flash based UIs using the AMF protocol for communication between the shop and the Flash/Flex/OpenLaszlo client. The ZendFramework - starting from version 1.7.0 - support the AMF protocol (thanks to a co-operation between Adobe and Zend). Has anyone else tried a similar thing or would be interested in following that approach?

In the end I envision something like a ZendFramework based module creating REST and AMF based APIs for Ajax/Flash clients and widgets.

Best,
Raju

Hi,

We have already implemented an amf gateway for oxid 4 - at the moment it is only interacting directly with the database and has only rought methods because it fits a special purpose, but I could help out if there are any questions regarding AMF/Zend. Here look at that designer on the front page it communicates via amf with the shop:

http://www.tshirt-selber-gestalten.de

Aggrosoft it intelligence GbR

Thanks for your response. Actually I’d like to get around accessing database tables directly. That’s easily done, but any modification or upgrade of the shop might break the functionality.

I’ll keep you updated on the progress here.

Cheers,
Raju

If you find any way to hook into the shop controller so we can use oxDb etc. that would be really great.

Aggrosoft it intelligence GbR

Ok, here’s what you need to include to use ZendFramework’s ZendAMF to access the shop classes. Have only tested with product data:

getConfigParam(‘iDebug’);
set_exception_handler(array(oxNew(‘oxexceptionhandler’, $iDebug), ‘handleUncaughtException’));

//strips magics quote if any
oxUtils::getInstance()->stripGpcMagicQuotes();

$server = new Zend_AMF_Server();
$server->setClass(“AMFProducts”);
echo $server->handle();

?>

Save this as amfservice.php in the shop root folder. Then create folder apitesting in shop root, add this class under the name of AMFProducts.php.

loadCategoryArticles(“8a142c3e60a535f16.78077188”, null, 10);
$aItems = array();
foreach ($oList as $oArticle) {
$oActCur = $myConfig->getActShopCurrencyObject();
$sPrice = $oArticle->getPriceFromPrefix().oxLang::getInstance()->formatCurrency( $oArticle->getPrice()->getBruttoPrice(), $oActCur );
$aItem = array();
$aItem[“id”] = $oArticle->_sOXID;
$aItem[“title”] = strip_tags($oArticle->oxarticles__oxtitle->value);
$aItem[“link”] = oxUtils::getInstance()->prepareUrlForNoSession($oArticle->getLink());
$aItem[“description”]= $oArticle->getArticleLongDesc()->value;
$aItems[] = $aItem;
}
return $aItems;
}

}

Note that there’s no closing ?>.

This is just a simple hack for now, but I can load the product listing into my Flex app through that. Adding more web services for basket, categories, etc. can be easily done using this approach. The most elegant way to continue would be to add a few lines to .htaccess to map calls like

http://www.yourshopurl.com/amfservice/products/ to something like http://www.yourshopurl.com/afmservice.php?cl=products

But maybe you have better ideas.

Raju

This is a really good base to work from, perhaps you could open up a google code repository or something like that - I would be willing to contribute into that because I have a lot of flex apps going the direct db approach and want to control everything through the shop system.

Aggrosoft it intelligence GbR

Thanks, good idea. We are planning to do a lot of Oxid work in the future, and we have done several open source products already. One example is the RIA frontend for the Alfresco Enterprise Content Management System, Docasu:
http://www.optaros.com/blogs/optaros-open-sources-docasu-10-ria-user-interface-alfresco-ecm

http://code.optaros.com/trac/docasu/wiki/Downloads

We have our own open source code repository, and I’d love to host such an Oxid module on that space: http://code.optaros.com/trac

Cheers,
Raju

what about SOAP/WSDL webservice? so the webservice can be used by external non-webbased programs coded in f.e. .NET

You can also communicate with .Net, Ruby etc. via AMF - have a look at weborb, and I think there are several other implementations for the protocol - SOAP has too much overhead.

Aggrosoft it intelligence GbR

why is soap too much overhead? complete ebay uses soap and so its more than easy to communicate with ebay. add items. del items. etc. an implementation like ebay has would be a great improvement to oxid and would be a lot more flexible instead of using several other ways. so u can access the webservice very easy with the most used programming languages.

an oxid shop cant be nearly as complex as ebay so the question is: what do ebay right :slight_smile:

Yes that’s true, but communication with the ebay api is slow, a good documented AMF3 api will not be too hard to understand and use either. And the good thing about using the zend framework will be that you can use nearly the same code communicate via SOAP/REST etc.

Aggrosoft it intelligence GbR

communication with ebay is slow because its a lot bigger and a lot more ppl accessing the api then u will ever have in an eshop with oxid.

i wish all systems would be so fast like ebay with the same amount of content ^^ believe me if ur eshop runs only 10% as fast as ebay with millions of articles that would be awsome ^^

if u can use nearly the same code to communicate in SOAP why dont u then provide a SOAP way? with f.e. .NET i can access SOAP/WSDL webservices directly without 3rd Party Tools. So i could provide the community with some .net classes.

Ok then we should start with a google code project. I have setup one here, sorry rajubitter but I think we should host it there because it is a quasi defactor standard and everybody can sign up easily there.

http://code.google.com/p/oxid-webservice-connector

Please send me your google mail address and i will grant you access.

Aggrosoft it intelligence GbR

Fine with me. Can you add me to the project? I’ll send you a message with my Google account email.

Best,
Raju

I have given you admin rights for the project, you could upload the code you already have into the svn as a starting point.

Aggrosoft it intelligence GbR

Caladan has joined our forces :wink:

Aggrosoft it intelligence GbR

y! ^^

lets see if i can later provide some .net classes for other ppl like me using oxid and non-web based programs with synching several things :slight_smile:

I have just checked in my first draft for the whole thing, I have setup a “No-Zend” connector because I do not want to use the Zend stuff at all (the zend amf implementation still lacks a lot of features, bytearray is broken, rest parameters are not respected etc. - not production ready in my opinion). Feel free to add a Zend version if you like to.

This first draft can already be used, just add the bridge.php into your oxid shop folder and upload the amf folder into the shop root. That’s all you have to do - I have modified the globals.php to include the bridge with all calls. The rest is business as usual, just add services to the services folder and connect to them via the gateway.php. The only difference is that you know have the possibility to use the oxid classes inside of your amf services. I will add a small sample service for putting stuff into the cart in the next days.

Aggrosoft it intelligence GbR

[QUOTE=aggrosoft;1404] I will add a small sample service for putting stuff into the cart in the next days.[/QUOTE]

Hi, can you please prepare example of service?