• Post Reply Bookmark Topic Watch Topic
  • New Topic

Web service calls in EJB method - legal or not

 
Steve Buck
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Want to know if its legal to the EJB 2.1 spec to have an EJB method call on a web service and retrieve data. The method would be called using Timer Service callback (thats the plan at least).

I've googled a few different terms and combinations but didn't find any results one way or the other.

thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve,
I think it's legal. I'm only about 80% sure though, so you should get a second opinion
 
Steve Buck
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrm...80% is optimistic. Anyone able to concrete this?
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking if it is legal for an EJB to call a Web Service? If so, then the answer is yes.
 
Steve Buck
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Tinnel:
Are you asking if it is legal for an EJB to call a Web Service? If so, then the answer is yes.


Precisely what I am asking. I'd like an EJB method to call a web service and be able to use the XML returned for some business logic.

I know EJB has lots of limitations so if it couldn't do that I wouldn't be surprised. Thats why I had to ask
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got a definitive yes, but I'll chime in with "I'm 80% sure too." The almost applicable prohibition on I/O here would be that EJBs may not open a ServerSocket on which to accept incoming connections. However, you are making a perfectly legal outgoing socket connection, so you're all good.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used web services, but here's one thing to watch out for. When calling an EJB method (even from TimerService I would expect), there is a timeout. If the method takes longer than the timeout to complete, the transaction (if any) is rolled back and the bean is invalidated (agani, not positive about this part). In any case, it's bad news.

Since you'll need to make many requests to the web service to get all the data transfered (assuming it can't all be streamed back at once), you'll need to make sure you set the timeout long enough for the whole thing, including your business logic, to complete.

Perhaps you could break up the transaction into pieces.
  • Request data, response tells you how much data
  • Make several requests to get chunks of data, write them to intermediate database table unprocessed
  • Process chunks of data from first table to final table(s)

  • Just a thought.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!