SOA with jsp-servlet

A

ahd292

Hi
I want to implement e-shopping system(as student project level) and
the architecture that must be used is SOA(service oriented
architectute). but I decided to do this by jsp servlet not web service
because I don't have enough time to learn web service, WSDL, BPEL and
more .

two other systems that my e-shopping system must be communicate with
them are "warehouse" and "bank". those system aren't complex and they
just support me with their services.
bank: validate credit of customer
warehouse: give information of stuff.

now I decide to gather them in one web application with three java
packages as their names.
but I don't now how to make relation with them by this approach,JSP
SERVLET.

does anyone can help me by providing simple application that support
SOA but with jsp-servlet.
 
L

Lew

ahd292 said:
I want to implement e-shopping system(as student project level) and
the architecture that must be used is SOA(service oriented
architectute). but I decided to do this by jsp servlet not web service
because I don't have enough time to learn web service, WSDL, BPEL and
more .

two other systems that my e-shopping system must be communicate with
them are "warehouse" and "bank". those system aren't complex and they
just support me with their services.
bank: validate credit of customer
warehouse: give information of stuff.

now I decide to gather them in one web application with three java
packages as their names.
but I don't now how to make relation with them by this approach,JSP
SERVLET.

does anyone can help me by providing simple application that support
SOA but with jsp-servlet.

Actually, SOA with servlets and JSPs is standard.

Think of it as the phrase, "service-oriented architecture", not the acronym,
"SOA". You can write to a service-oriented architecture in BASIC, let alone
Java, let alone using SOAP or BPEL. The point is to write your components as
services, and have them communicate through a service-to-service communication
layer.

When you do it from a web application, that makes it a web service. No
mention yet of SOAP. But now that we have mentioned SOAP, it might be the
fastest way to a fully-functional prototype.

First, write a conventional web app using JSPs, a servlet and Java logic to
invoke a service. This service will be called by direct function calls from
some logic invoked by the controller servlet. No SOAP. But the service class
needs to be independent, preferably defined by an interface with an
implementing class that the client logic cannot see.

Example:

package example.soa.service;
import java.util.Collection;
import example.soa.model.Good; // an interface
public interface WarehouseService
{
public void stash( Collection <Good> goods );
public Collection <Good> retrieve();
}

Then you cheat. You run Java2WSDL over the interface to create a WSDL.
Eclipse and NetBeans both do this automagically for you, I believe. Otherwise
you get it from the Axis project. Then you run WSDL2Java over the WSDL to
generate client and proxy stubs for a client. Next you write a cover class
that invokes the Locator, retrieves a local instance of the interface type
that actually calls the proxy, and then simply calls the methods of the interface.

Finally, you create a client web project that uses the URL of the server web
project to fulfill its logic requests. The JSP view page(s) can be
near-clones of the JSPs from the server-side "direct" application. (Change
the titles to confirm that you're viewing from the client.)

I'm waving all sorts of magic wands here. There is a learning curve, which
the IDEs can help you gloss over. You have to get all the right JARs into
your project library (deployed WEB-INF/lib/ directory). Still, about a week
of dedicated practice should get a crude but deployable and runnable prototype
going.

Truth to tell, just constructing the services as independent interfaces with
hidden (i.e., package-private or quieter) implementor classes, preferably
instantiated through a (configurable) factory class, already has you in a
service-oriented architecture. That's what makes it easy to break up the
calls across a web-app-to-web-app communication gap. A local class implements
the interface via direct calls, a remote one via proxies and stubs.

Plus you can probably get partial credit for the local implementation of a
true SOA even if you fubar the remote implementation.

Having a working local version lets you know better where a broken remote one
is actually not working. Sensible separation into layers has already
happened. You can ask focused questions in Usenet, because remoteness issues
will have been teased away from all others.

One practical basis for SOA is to think, always, interface-wise.
 
A

Arne Vajhøj

Lew said:
Actually, SOA with servlets and JSPs is standard.

Servlets are frequently used at the server side/producer for
web services.

I have never seen a JSP page used as such.

Neither should be used for client side/consumer.
Think of it as the phrase, "service-oriented architecture", not the
acronym, "SOA". You can write to a service-oriented architecture in
BASIC, let alone Java, let alone using SOAP or BPEL. The point is to
write your components as services, and have them communicate through a
service-to-service communication layer.
Yep.

When you do it from a web application, that makes it a web service.

No.

web application = something for humans with a browser

web service = something for programs (using same technology as web app)
No
mention yet of SOAP. But now that we have mentioned SOAP, it might be
the fastest way to a fully-functional prototype.

SOAP has excellent tools support.

[example of how to do web service in Java removed - I agree with
all that]
Finally, you create a client web project that uses the URL of the server
web project to fulfill its logic requests. The JSP view page(s) can be
near-clones of the JSPs from the server-side "direct" application.
(Change the titles to confirm that you're viewing from the client.)

Typical the web services would be used at a lower/far behind (depending
on how you draw it) layer/tier.

A simple JSP page front end is typical only done for testing.
Truth to tell, just constructing the services as independent interfaces
with hidden (i.e., package-private or quieter) implementor classes,
preferably instantiated through a (configurable) factory class, already
has you in a service-oriented architecture. That's what makes it easy
to break up the calls across a web-app-to-web-app communication gap. A
local class implements the interface via direct calls, a remote one via
proxies and stubs.

I would say implementing a good SOA solution is a bit more complex
than that.

Arne
 
L

Lew

Servlets are frequently used at the server side/producer for
web services.

I have never seen a JSP page used as such.

By that I simply meant that the JSP is the view side of some application that
drives the use of web services at the back end, where in times past one might
have expected a local application or data store.

You are absolutely correct that automated processes are a strong, perhaps teh
strong use case for web services, but even such processes in the end serve a
reporting or interactive system. OTOH, many of those have no use for JSP.

The purpose of JSPs to which I alluded upthread was as dashboards for logic
that invoked web services behind the scenes, and that is the
application-to-application layer to which you refer.
Neither should be used for client side/consumer.

Not directly, I completely agree. As JSPs are often used as front ends to
large-scale enterprise processes, but of course other front ends also exist,
they might drive processes that in turn use services, including web services.
No.

web application = something for humans with a browser

web service = something for programs (using same technology as web app)

Good point.
SOAP has excellent tools support. ....
I would say implementing a good SOA solution is a bit more complex
than that.

I endorse Arne's comments and corrections.
 
P

Patrick May

Lew said:
Actually, SOA with servlets and JSPs is standard.

Think of it as the phrase, "service-oriented architecture", not the
acronym, "SOA". You can write to a service-oriented architecture in
BASIC, let alone Java, let alone using SOAP or BPEL. The point is
to write your components as services, and have them communicate
through a service-to-service communication layer.

This is an extremely important point: SOA is not a synonym for
Web Services (SOAP and WSDL). Web Services are just one, particularly
inelegant, way of implementing an SOA.

For what the original poster is trying to do, Jini services are a
much better approach. They are lightweight and easily invocable from
Java servlets. See http://www.jini.org for details, including several
introductory tutorials.

Regards,

Patrick
 
A

ahd292

Hi
Thanks of your reply posts
By guides of Lew, I began to design my project in Interface-wise form
as he said.

As I said before, my three applications are in one project and with
this I have to divide them in packages same as following structure:
(packages are shown in <>)

<Frontend.Shopping>
jsps: ....
<frontend.shopping.Bean>
C: Order,Customer
<frontend.shopping.controller>
C: OrderController, CustomerController
<frontend.shopping.controller.services>
Servlets: StuffServiceReciever, BankServiceReciever
<frontend.shopping.DBHandler>
C: OrderDBHandler, CustomerDBHandler

<Services.Bank>
C: Account, AccountDBHandler
Interface: AccountValidationService
C: AccountValidationServiceImpl
<Service.Warehouse>
C: Stuff, StuffDBHandler
Interface: StuffInfoService
C: StuffInfoServiceImpl

by this Structure when a customer enter term in the searchBox on jsp
page, "StuffServiceReciever" called from that jsp page. now here is
the where we must see the "Service oriented architecture" .
in this Servlet(Controller from MVC) I wrote following statement:

StuffInfoService Istuff = new StuffInfoServiceImpl();

of course I import it's package. then I use desire methods of Istuff.
1)First I want to Know is this style of relations true or must be
changed?
2)How can I send those recieved info(that maybe in form of array of
Stuufs) to jsp page. if I use javabean and usebean tag then can I send
bean from servlet to jsp?

and about Jini taht Patric suggests, I hava not yet enough time to
deeply find out how can help me and how can relate to Servlets. But If
you believe this is better way can give me some quick start or sample
related to this projects?

thanks very much!
 
P

Patrick May

ahd292 said:
As I said before, my three applications are in one project and with
this I have to divide them in packages same as following structure:
(packages are shown in <>)

<Frontend.Shopping>
jsps: ....
<frontend.shopping.Bean>
C: Order,Customer
<frontend.shopping.controller>
C: OrderController, CustomerController
<frontend.shopping.controller.services>
Servlets: StuffServiceReciever, BankServiceReciever
<frontend.shopping.DBHandler>
C: OrderDBHandler, CustomerDBHandler

<Services.Bank>
C: Account, AccountDBHandler
Interface: AccountValidationService
C: AccountValidationServiceImpl
<Service.Warehouse>
C: Stuff, StuffDBHandler
Interface: StuffInfoService
C: StuffInfoServiceImpl [ . . . ]
and about Jini taht Patric suggests, I hava not yet enough time to
deeply find out how can help me and how can relate to Servlets. But
If you believe this is better way can give me some quick start or
sample related to this projects?

When developing an SOA you should think of the web front end as
just another user interface. Under no circumstances should you couple
that UI to your database schema. In the beginning of your design
process you should focus on the behavior associated with your use
cases (or even just a single use case if you're using an agile
methodology). If a database is required, that will become evident
when designing and implementing particular services.

Based on your description, it appears that one of your use cases
is Order Stuff. To order stuff, you need to pass an order for a
particular customer to one or more services that can execute the
order. This is known as an Order Management System (OMS). For a
first cut, consider creating a Jini service called
OrderManagementSystem with a method called placeOrder() that takes an
Order object. This would be arguably bad design for a standalone OO
system, but services are often at a coarser level of granularity than
classes.

When an order is received by the OrderManagementSystem, it must
be processed via some workflow. The steps in this workflow may
include customer verification, credit checking, billing, provisioning,
shipping, etc. Each of these steps should be performed by a separate
service. The workflow can be mediated by the OrderManagementSystem
service but Jini offers JavaSpaces as another alternative. A
JavaSpace is a Jini service that is used for collaboration by other
Jini services. When the OrderManagementSystem service receives an
order, it can write it into a JavaSpace to make it available to the
other services that participate in the workflow. When the order is
processed or when any exceptions occur, the result is written to the
JavaSpace where it can be picked up and presented to the customer.

This is obviously a very rough explanation based on very little
information about your requirements. I hope it gives you a flavor of
how to use Jini to build an SOA.

Regards,

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top