wood burning stoves 2.0*
The moose likes Web Services and the fly likes Design Pattern To Migrate BL As Web Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Design Pattern To Migrate BL As Web Services" Watch "Design Pattern To Migrate BL As Web Services" New topic
Author

Design Pattern To Migrate BL As Web Services

Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Hello all,

I am working on enterprise application that is build using GWT, Struts 2 and Hibernate 3. I am following complete MVC architecture in which I have presentation in GWT, Action layer in Struts 2 used by client, BL as Facade layer used by Action layer and persistence layer used by facade layer. Now I want to expose my facade layer methods as web services as soon as possible and that in maintainable and scalable manner.

I am not having much knowledge regarding web services or J2EE design patterns. I have heard about Axis framework but don't have much knowledge about that. Kindly suggest which are good frameworks which I can use to expose web services and which pattern will be good to use in this case.


Thanks & Regards,
Vishal S Shukla (SCJP 93%, SCWCD 94%, SCBCD 100%)
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Now I want to expose my facade layer methods as web services as soon as possible and that in maintainable and scalable manner.


Why do you want to do this? If you don't have knowledge about web services, it is hard to understand how you know that this is what you want. Very confusing.

Anyway, web services are for connecting applications. It is an integration technology, not an implementation technology. So, are there other applications that you want to the be able to communicate with the one you are currently working on?

Axis is a good framework to create web services.

In regards to patterns, you first need to identify what type of web service you want, e.g. data-centric, process-centric, functionality-adding, etc.
The Facade and Adapter pattern are helpful once you know what you are doing.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why not just continue to use your Struts 2 layer to expose services? Creating RESTful services using the technology you already have in place would be pretty straight-forward. Or, if you're already using Spring integration, consider its support for services.

Assuming your application is already reasonably partitioned, it's usually a matter of taking your existing services and creating a minimal service request wrapper around them. Blindly seeking patterns to apply to the problem is premature--doesn't look for patterns, find them.
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
If you don't have knowledge about web services, it is hard to understand how you know that this is what you want. Very confusing.


Sorry for confusing statements. What I want to convey is, I am clear in basic concepts of web services but haven't worked on it practically ever and don't have in-depth knowledge of concepts also.

I don't need to communicate with other application but due to new deployment requirement, Web server and BL layer need to be separated. So I decided to expose BL layer methods as web services. The application is in half developed state, so I was looking around for some smart way so that there will be minimal changes in the consumer of web services.

you first need to identify what type of web service you want, e.g. data-centric, process-centric, functionality-adding, etc.

Again I haven't heard of any of these type of web services. Trying to give you idea about what exactly these web-services will do is abstracting business process, delegating calls to dao layer for CRUD operations, making decisions for workflow (just because of dynamic behaviour of workflow.).

Why not just continue to use your Struts 2 layer to expose services?


I am not sure whether it will be possible to separate web-application deployment and BL layer deployment with this approach? One more doubt is that As I am using GWT layer as front-end, most of the server calls are AJAX calls. So will there be any issues because of that? It would be great if you put some more light over these issues or suggest some tutorial for the same.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The type of call made to Struts isn't relevant--what's important is what you need back. Considering that there's trivial support for returning JSON, XML, or XHTML, I'm not sure where the confusion is.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Vish, first you are using the letters 'BL' to mean something. Is this some acronym that you just made up? Please use English words instead. This
will foster better understanding for readers with English as a second language.

I don't need to communicate with other application but due to new deployment requirement, Web server and BL layer need to be separated. So I decided to expose BL layer methods as web services.


Assuming that your 'BL' means business logic, a lot will depend upon how this is implemented. Is it a group of plain Java-based objects, or is it a group of Session EJB? Either way, separating these two components is not a mystery nor something new.

I think you need to learn more about web services. More about the problems with them and the overhead and the maintenance. You seem to have made a pre-mature decision to use a technology that you don't understand, in my opinion.

Also, it looks like you could benefit from learning about Session EJB (remote connectivity), JNDI and the Business Delegate design pattern.
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
James, you are right, I have used BL as acronym for Business Logic. I haven't used EJB, this layer has plain java-based objects only(not beans).

I think you need to learn more about web services. More about the problems with them and the overhead and the maintenance. You seem to have made a pre-mature decision to use a technology that you don't understand, in my opinion.


I am here only because I need to learn many things in that. Any ways, I want to finalize on which technology/patterns to use which I need to do in very less time, so my thought was if I can get couple of directions which can solve my problem, it'll save a lot of time.

If prime requirement is for separate only, and Web server & application server are going to be in intranet, can session-bean solve the issue? Can you please suggest some book where I can get overall idea of technologies and which can give me knowledge to make right decision.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
If prime requirement is for separate only, and Web server & application server are going to be in intranet, can session-bean solve the issue? Can you please suggest some book where I can get overall idea of technologies and which can give me knowledge to make right decision.

Assuming that your use of the term "separate" means on different machines using different JRE instances, then yes, Session EJB can provide a solution. A RMI server can also provide a solution. Any book about Enterprise JavaBeans or RMI will help.


Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Thanks a lot James..

Just want to confirm one point.. Will it matter if my web tier server and business logic tier server are on same Intranet or on different network in Internet?
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187


The terms "intranet" and "internet" represent different things.

It will matter slightly. "dedicated" communication over the internet will be slightly more complicated and the non-functional requirements would be different. However, machines have been communicating via internet for over 40 years. I suggest initial study in RMI and then move into Enterprise JavaBeans. Also, it looks like you need to learn a bit about about network programming (Socket programming in Java).
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
James, I think I was too lazy in typing in last post.. My last question was related to Enterprise JavaBeans only. I meant if I am going for EJB, then EJB server should be on the same network in which Web server is located? If its not necessary that they should be on same network, then what kind of "complication" it will add if they are on different networks on internet.?

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
This goes back to what you meant by "separate". If the web application is on a totally different network than the EJB application, then creating web services to allow these two applications to communicate is a good design decision. These would be classified as process-centric services.

In regards to the alternative, you would need "dedicated" and "secure" connections between the two networks to enable them to communicatie via TCP/IP protocol. You would need to set up comprehensive firewall (DMZ) systems in both networks.

If the web application and the EJB application are hosted on different machines, BUT, in the same network, then setting up web services to enable them to communicate is not a good design decision, in my opinion. This is base on my limited understanding of your organization, your industry, and what your application actually does.
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
James, Thanks for really nice explanation. I am not able to give you exact requirement is because this application is a product which will be deployed to n different clients. So there is possibility that these server will be on different networks. So I think I need to find out probability that what is more possible requirement. And there is trade-off in both the solutions as it will vary in each deployment.

Can you give your suggestion for how severe it is to use web service in "Intranet architecture"(Sorry for laziness again in writing whole sentence here) and how severe impacts will be there in using EJB in "architecture with different networks".
Vish Shukla
Ranch Hand

Joined: Oct 12, 2008
Posts: 111
Finally, got the missing link from other sources.. Just for other readers' information, when using EJB for remoting, it doesn't matter whether its on intranet or internet. Its just that if there are proxies or firewalls, you need to do security related compromises. In which case, you can always expose SessionBean as web service which will work through Port no 80 and uses HTTP.

Thanks to James, David & JavaRanch for help...


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Design Pattern To Migrate BL As Web Services