Meaningless Drivel is fun!*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Is it necessary to use statless sessiob bean as proxy to web service? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Is it necessary to use statless sessiob bean as proxy to web service?" Watch "Is it necessary to use statless sessiob bean as proxy to web service?" New topic
Author

Is it necessary to use statless sessiob bean as proxy to web service?

Anil Chowdary
Ranch Hand

Joined: Jan 20, 2009
Posts: 43
Hi All,

I have finally decided to use a proxy class to integrate a web service with my system. I had gone though the forum and a lot of people earlier used a statless session bean to act as a proxy to a web service. It sound little strange to me for the simple reason that a proxy can be a simple Java class. Any type of web service client(Static proxy/Dynamix Proxy/Dynamic Invocation Interface) you can create as a simple java class. So I'm wondering is there a special advantage of creating it as a stateless session bean?

Thanks,
Anil


OCMJEA/SCEA, SCWCD, SCJP
Senthil Kumar
Ranch Hand

Joined: Mar 13, 2006
Posts: 264
any opinions on this. I'm using SLSB as a web proxy. The reason i have is it would scale better when we have more app servers.


when you really want something, all the universe always conspires in your favour.<br /> <br />SCJP1.5-77%<br />SCWCD-89%
Anil Chowdary
Ranch Hand

Joined: Jan 20, 2009
Posts: 43
Fair enough. Even I end up using a SLSB for the assignment part.

But in reality, even you make it as a simple class it can still be scalable. If you have the flexibility to increase the app servers, the same applies for web servers. Just a thought.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Anil Chowdary wrote:Fair enough. Even I end up using a SLSB for the assignment part.

But in reality, even you make it as a simple class it can still be scalable. If you have the flexibility to increase the app servers, the same applies for web servers. Just a thought.


Did you put something between SLSB and WebService?, kind of DAO or Adapter?


SCJP 5.0, SCWCD 5.0, SCBCD 5.0, SCEA/OCMJEA 5.0
Anil Chowdary
Ranch Hand

Joined: Jan 20, 2009
Posts: 43
Yes, I have a layer in between by SLSB and the web service. But I didn't name is as DAO. I just called it as <ServiceName>Client. This is a plain java class that acts as client to the webservice.
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Anil Chowdary wrote:Yes, I have a layer in between by SLSB and the web service. But I didn't name is as DAO. I just called it as <ServiceName>Client. This is a plain java class that acts as client to the webservice.


As for <ServiceName>Client class, what pattern it represents?. What are the responsibilities of this class?
Ethan Zhang
Ranch Hand

Joined: Mar 19, 2008
Posts: 46
Why need additional layer? To assemble object from xml? Why can't be implemented in SLSB? So what's in SLSB? Thanks.

Anil Chowdary wrote:Yes, I have a layer in between by SLSB and the web service. But I didn't name is as DAO. I just called it as <ServiceName>Client. This is a plain java class that acts as client to the webservice.


The Devil Wears Cartier Trinity
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Ethan Zhang wrote:Why need additional layer? To assemble object from xml? Why can't be implemented in SLSB? So what's in SLSB? Thanks.


Finally I decided to use only SLSB as my WS client. I will add it to the integration layer in my Component Diagram.
Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
so SLSB as the WS client, is actually SLSB as the WS Proxy ?


SCJP, SCWCD, OCMJEA, OCEEJBD, OCEJPAD, TOGAF® 9 Certified, OCEJWSD
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Luay Abdulraheem wrote:so SLSB as the WS client, is actually SLSB as the WS Proxy ?


If you want to call it WS Proxy. For me it is just a WS client implemented as SLSB.
MarioAixel Rodriguez Jaen
Greenhorn

Joined: Mar 13, 2007
Posts: 15
Anil Chowdary wrote:Fair enough. Even I end up using a SLSB for the assignment part.

But in reality, even you make it as a simple class it can still be scalable. If you have the flexibility to increase the app servers, the same applies for web servers. Just a thought.


Anil,

The coolest thing about using SLSB is the flexibility. Think for example in the scenario that you can deploy the SLSB in another app server. You can thus point to many other clusters of EJBs by IP and not worry about deploying the presentation layer. In that sense it is more flexible than any simple java object.


Mario Rodriguez Jaen
SCJP1.4, SCJD1.4
Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
In the component diagram, when we say that our SLSB will be in the business tier or in the integration tier, that means that both (Interface + Bean"Interface Implementation") are considered as one component, right or wrong ?
Nilessh Ganu
Ranch Hand

Joined: Dec 22, 2009
Posts: 100
Krzysztof Koziol wrote:
Luay Abdulraheem wrote:so SLSB as the WS client, is actually SLSB as the WS Proxy ?


If you want to call it WS Proxy. For me it is just a WS client implemented as SLSB.


In my view, if SLSB is the WS client, it should not be called WS proxy. The WS proxy should ideally have a reference to the "real subject" class. To use dependency injection, this "real subject" class should be managed by container. So should this "real subject" will also be SLSB, something like:

@stateless
public class RealWSSubject{

@WebServiceRef
// web service consumer

}

@stateless
public class WSProxy{

@EJB
RealWSSubject realSubjectRef;
// using real subject

}

Am i missing anything ?


Nilesh
SCJP SCWCD OCMJEA
Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
mm .. looking back to your example Client and Proxy seem to be different objects. Krzysztof said they are the same, but you can choose the naming of that one object (if I'm not wrong) The question now : it seems to me that there is no need to use an additional layer SLSB WSProxy in your example ? What is the use of it ? can someone please help !

P.S : I haven't worked on a web service client consumer as an SLSB before, thats why I'm asking alot
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Guys, I said that SLSB can be used as WS client. There is no need to add other supporting beans.
Luay Abdulraheem
Ranch Hand

Joined: May 18, 2011
Posts: 65
Thanks Krzysztof for clearing out some points.

What about both (Interface + Bean"Interface Implementation") are considered as one component, right or wrong ?
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

I'm not providing any interfaces in my design.
Gurukant Desai
Ranch Hand

Joined: Apr 07, 2008
Posts: 56
In this case the SLSB implemented with @WebServiceRef annotation will still be in business tier, right?

Although it is also doing job of WS client, it will not be in integration tier, right?
Krzysztof Koziol
Ranch Hand

Joined: Nov 19, 2006
Posts: 133

Gurukant Desai wrote:In this case the SLSB implemented with @WebServiceRef annotation will still be in business tier, right?

Although it is also doing job of WS client, it will not be in integration tier, right?


In my opinion it should be in the integration tier since it job is to send requests and receive responses from WS server. Except converting requests from XML to POJOs (done automatically by JAXB) there is no business logic executed by this SLSB.
 
GeeCON Prague 2014
 
subject: Is it necessary to use statless sessiob bean as proxy to web service?