views:

102

answers:

2

Hello all,

I've got a scenario where we have a customer who has a linux hosted php app (joomla) that they wish to integrate with some back-end asp.net mvc functionality that was created for a 'sister' site. Basically, the mvc site has prices and stock availability methods which (in the sister site) populates dropdown lists and other 'order' style info on the pages. I've been tasked with looking at the integration options to allow the php site to use this info as a 'service'. (as ever, these guys are looking at cost of ownership, maintenence etc, so this is their preferred route)

Has anyone done anything similar with success?? I'd imagine (much like the sister site) liberal doses of ajax will be employed in order to populate portions of the page on demand. So this may have a bearing on any suggestions that you may have. Also, the methods that are being called ultimately end up populating the same database, so there are no issues with correlating the ID's across the different platforms.

I don't really want to go down any 'iframe' type route if at all possible, tho' reality may dictate this as being an option. I'm possibly (naively) imagining that i could simply invoke the mvc functions directly from the php app with some sort of 'session' variable being passed for authentication.

pretty tall order or pretty straightfwd??

cheers

jim

[edit] - tho highly unlikely to be implemented due to the existing structure of the joomla site, would the use of an openID account help to 'glue' the two sites together??

also, found this little article that 'may' go some way twds what I'm thinking of: http://www.jeffancel.com/archive/2009/04/05/70.aspx

+1  A: 

You best bet is to create asp.net web services or wcf services that provide the info you need. You can then consume these services from your php site. If you already have classes and methods that provide the data then it is really easy to just expose them as web services.

Ben Robinson
Ben, yes that was an option that I'd have definately used in my webforms apps and could most certainly be used here.i did find an interesting approach here which allowed a jsonp callback action filter to be used in php. i've created a little test case and this seems to work fine.http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx
jim
+1  A: 

If authentication is a factor, you could use an API KEY to tell the .net application who you are, also, they can add filters that would only allow consumption from certain resources. From PHP, there are a couple ways that you can consume .net services as I have done it several times. If you call from the server side (actual PHP), then you would want them to expose the data you are consuming in xml or json; so you can parse it in PHP and use it the way you want to. Here are a couple routes I can suggest:

1.) Ajax or request into your PHP application, which in turn uses PHP to consume the services from your sister site; in worst case scenario, you may have to parse html directly, though I would suggest having them open up the XML or JSON object using a RESTful service (this is a fairly easy modification if you don't mind adding a couple of methods in your controller).

2.) Ajax using a jsonp request to grab an html widget from the site that you are communicating with. This would require some work by the sister site as well, but it is very doable. If you go this route, then they must make the cross domain changes that I mentioned in that post (though that is .net mvc 1.0).

In the end, it boils down to your specific requirements as to what you would choose. I personally choose route 1 and consume most services from the server side as it can abstract things such as API-Keys and other things I don't want the users to see. It is also easier to deal with XML from PHP rather than javascript because of the individual browser behaviors (ie versus firefox et al.).

Jeff Ancel
Hi Jeff,I think option 1 would be my preferred route too. in fact, based on the eaxmple at http://blogorama.nerdworks.in/entry-EnablingJSONPcallsonASPNETMVC.aspx i did manage exactly that. my useage will be mainly jquery access from the php app (i've tried this and it works fine). i am however intrigued by your API key suggestion. would this be issued from the php app->client browser->.net controller action??
jim
.. sorry noticed that you mantioned the API key's in relation to server side abstraction..
jim
any thoughts on the 'integrity' of using an md5 around context.HttpContext.Request.UrlReferrer.AbsoluteUri and then comparing that on the .net side??
jim