• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web service calls in EJB method - legal or not

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hrm...80% is optimistic. Anyone able to concrete this?
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic