Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Call Scout Service from webpage
Call Scout Service from webpage [message #1110840] Tue, 17 September 2013 07:47 Go to next message
Bertin Kiekebosch is currently offline Bertin Kiekebosch
Messages: 300
Registered: August 2011
Senior Member
Hi,

I need to get some data from and transfer some results back from a web page. (Regular site HTML5 CSS and Javascript) This data is already available for a swing client in a Scout Server and whats even more important when the data is stored, all the business rules are already implemented in the Scout Service.

Is it advisable to get and send data from a regular website to a Scout Server and if yes what is the best way to do this.

Regards Bertin
Re: Call Scout Service from webpage [message #1110849 is a reply to message #1110840] Tue, 17 September 2013 08:02 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan Motsch
Messages: 100
Registered: March 2010
Senior Member
Hi Bertin,

indeed i would re-use those services whenever possible.

Html 5 Webpages exist with or without back-end servlet/jsp/php,...

A) Page with server side php/jsp/..:
Simply call the Scout Service using a Scout Transaction. Therefore you Need a Scout Server session for that user as well as a security subject (javax.security).
The session can be obtained in the same way as the Scout servlet
ServiceTunnelServlet
does it.

  private IServerSession lookupScoutServerSessionOnHttpSession(HttpServletRequest req, HttpServletResponse res, Subject subject, UserAgent userAgent) throws ProcessingException, ServletException {
    //external request: apply locking, this is the session initialization phase
    synchronized (req.getSession()) {
      IServerSession serverSession = (IServerSession) req.getSession().getAttribute(IServerSession.class.getName());
      if (serverSession == null) {
        serverSession = SERVICES.getService(IServerSessionRegistryService.class).newServerSession(m_serverSessionClass, subject, userAgent);
        req.getSession().setAttribute(IServerSession.class.getName(), serverSession);
      }
      return serverSession;
    }
  }


The subject can be used either from the webcontainer itself (WLS)
 Subject subject = Subject.getSubject(AccessController.getContext());

or by creating one
Subject subject=new Subject();
subject.getPrincipals().add(new org.eclipse.scout.commons.security.SimplePrincipal(...));


Finally simply use

new ServerJob("web",session, subject){
  protected IStatus runTransaction(IProgressMonitor monitor){
    //your code goes here, you can use HttpServletRequest, HttpServletResponse etc. as well
    SERVICES.getService(...).doWhatever();
  }
}


B) Page without server side php/jsp/..:
In this case i would create a subclass of
ServiceTunnelServlet
and override
doPost()
and
doGet()
.
There detect your Webpage request for example by using an additional URL path or a URL Parameter. Then it continues similar to A).

B2) You may also write a complete new servlet and using the concepts in A) Server Ajax Clients with exactly the protocol you Need, for example json.


Does this help?
Re: Call Scout Service from webpage [message #1110891 is a reply to message #1110840] Tue, 17 September 2013 09:16 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 622
Registered: October 2011
Senior Member
Isn't your question related to the question you posted a long time ago: Calling Scout from Mobile Device

The answer from Ivan is much better than mine...
Previous Topic:Tree with multiple columns like SWT or JFace Tree
Next Topic:Modifying SWT look and feel for disabled elements
Goto Forum:
  


Current Time: Tue Jul 22 23:57:37 EDT 2014

Powered by FUDForum. Page generated in 0.02028 seconds