Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld >> Enterprise Java

Pages: 1
Alucard
stranger


Reged: 07/16/08
Posts: 6
PHP-Servlet-EJB - design choice?
      #173872 - 07/16/08 04:15 PM

Hi,

I'm looking into implementing an EJB-based service for integration into existing web-site. Website is written on PHP and hosted on standard ISP hosting. There is also a dedicated server which is the base for business logic processing.

My goal is to implement business logic processing using high-level language with adequate debugging abilities, e.g. Java, employ HTTP-based connectivity and make little change to existing website code.

Here is design I came up with: there is a PHP class on website-side, which provides business logic methods (i.e. getProductListing(), sendOrder() and such).
This class translates incoming method calls to HTTP requests on socket, which connects to a servlet on dedicated server. The servlet handles requests with help of EJB and sends back an XML response. XML response received by same PHP wrapper class, processed with XSLT and displayed on web site page.
Servlet and EJB running under JBoss AS.

Here go the questions:

1. Is there anything to be improved in this design?

2. There is an issue of handling session contexts. Servlet cannot discern users, since from its standpoint, there is only one connection source - PHP wrapper class. So there is need for PHP wrapper to manually supply JSESSIONID cookie from servlet to the browser and back.
Do you think there is any better way to handle this?

3. Which is the best way to handle session context on servlet/EJB side? I'm looking at JBoss Seam, but not convinced it will do because of previous issue. I'm looking into manually implementing session context tracking on servlet side, but there probably is a better solution?

Please let me know your opinion on this design. Feedback is much appreciated.


Post Extras: Print Post   Remind Me!   Notify Moderator  
PAK
stranger


Reged: 07/22/08
Posts: 1
Re: PHP-Servlet-EJB - design choice? [Re: Alucard]
      #175384 - 07/22/08 02:45 AM

Hi.
I've got an experience in implementing similar system. That system in addition consists of an EJB core application (JBoss server) and a public web site (Apache+PHP).
EJB core application supplies its services as Web Services (using session beans and @WebService annotation).
Then there is a PHP client adapter to access such Web Services. This adapter establishes connection to JBoss application and translates site business-logic method calls to web service method calls (using SoapClient: http://php.net/manual/en/book.soap.php).
Ask yourself, do you really need a session context in your EJB application? You can just secure your ejb session bean methods, and then implement authentication in connection method of the PHP adapter. Then you establish secured connection to EJB, if the user is logged in (i.e. assuming PHP session context variables).


Post Extras: Print Post   Remind Me!   Notify Moderator  
Alucard
stranger


Reged: 07/16/08
Posts: 6
Re: PHP-Servlet-EJB - design choice? [Re: PAK]
      #175826 - 07/24/08 07:57 AM

Cool! Seem like this is rather rare experience
May be I do not actually need session context as such. EJB has to know at least user id which invokes a method, and this can be obtained on authentication step. This, though, would raise some security concerns, as you point out.
Still, I have no experience in EJB, so I have difficulty choosing most effective solution.
My constraint is such that I'd like to apply minimal possible change to PHP-side, whether in code or in configuration. PHP session id is already there, so I'm looking for a way to get by with it.
Also, is there some benefit in using WebServices as opposed to writing HTTP requests to a socket, open from PHP to servlet, except for better reusability?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 5585

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5