Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Call Scout Service from webpage
Call Scout Service from webpage [message #1110840] Tue, 17 September 2013 11:47 Go to next message
Bertin Kiekebosch is currently offline Bertin KiekeboschFriend
Messages: 330
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 12:02 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan MotschFriend
Messages: 154
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 13:16 Go to previous message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
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: Fri Mar 29 14:04:56 GMT 2024

Powered by FUDForum. Page generated in 0.05595 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top