Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:25:30+00:00 2026-05-23T05:25:30+00:00

I have a method which opens a web service session. The method structure looks

  • 0

I have a method which opens a web service session. The method structure looks something like this:

public Soap getServicePort()
{
   //TODO: Open a connect and return the SOAP object
   return soap;
 }

I have a requirement to add a monitor straight after the return. The monitor’s job is to wait for 2hrs and in-activate the session and rebuild a new one – well reason been the current session will be invalid at that time and therefore we need to rebuild and return a new session.

Can anyone suggest a reasonable way of doing this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:25:31+00:00Added an answer on May 23, 2026 at 5:25 am
    public Soap getServicePort()
    {
        try {
       return soap;
       } finally {
          // add monitor here.
       }
     }
    

    But be careful: monitor should not throw exceptions. Put its initiation ito try/catch.

    Probably better solution is wraper pattern. For example you can define interface with method getServicePort() and 2 implementations: one your real implementation and other that wraps real and adds monitor. This solution is more flexible. For example probably you will have to create your monitor afeter other methods and even after other methods implemented in other classes.

    In this case you can use AOP. There are several ways to use it. One is using Dynamic Proxy of java. Other is using special tools like AspectJ.

    So, choose your solution. Your choice should depend on the complexity of your task and number of methods/classes that required to implement this functionality. If it is only one method use try/finally, if it is several methods in the same class, use wrapper pattern. If it is required for several methods in several classes use Proxy or AspectJ.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a web service that works with a database. Each method opens
I have a library which I would like to expose as a SOAP web
I have this code: s(x => x.Open()); s is a method which calls one
I have an Activity which looks up data from the web in its onCreate
I have a web service to which I send a xml request (application/x-www-form-urlencoded encoded)
I have written a sample web service, which consist of certain .aspx pages. I
I'am going to have to interact with a SOAP web service, using a C++
I'm working with a VB.Net page which calls a web method from JavaScript, this
I have an ASP.Net MVC site, which connects to a web service. The site's
I have a method which takes params object[] such as: void Foo(params object[] items)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.