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 135989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:52:39+00:00 2026-05-11T06:52:39+00:00

Similar to How can I access the ServletContext from within a JAX-WS web service?

  • 0

Similar to How can I access the ServletContext from within a JAX-WS web service?, is there a way to access applicationContext, easier than this?

import javax.annotation.Resource; import javax.jws.WebService; import javax.servlet.ServletContext; import javax.xml.ws.WebServiceContext; import javax.xml.ws.handler.MessageContext;  import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils;  @WebService public class MyWebService {     // boilerplate code begins :(      @Resource     private WebServiceContext context;     private WebApplicationContext webApplicationContext = null;      /**      * @return      * @throws IllegalStateException      */     private WebApplicationContext getWebApplicationContext()             throws IllegalStateException {         if (webApplicationContext != null)             return webApplicationContext;         ServletContext servletContext =                 (ServletContext) context.getMessageContext().get(                         MessageContext.SERVLET_CONTEXT);         webApplicationContext =                 WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);         return webApplicationContext;     } } 
  • 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. 2026-05-11T06:52:40+00:00Added an answer on May 11, 2026 at 6:52 am

    I don’t think that the web service should have to know about web or servlet contexts or its application context. I don’t see why it should have to know any of that. Shouldn’t it be far more passive? Inject what it needs and let it do its work. The service interactions with a client should be based on a contract defined up front. If it has to get unknown values from a context of some kind, how will clients know what needs to be set or how to set it?

    I’d go further and say that a web service should be a wrapper for a Spring service interface. It’s just one more choice among all the possible ways to expose it. Your web service should do little more than marshal and unmarshal the XML request/response objects and collaborate with Spring services.

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

Sidebar

Related Questions

In asp I can access the log file in \Inetpub\logs\LogFiles\W3SVC1 there something similar on
This topic can look similar to others but I haven't found any usable answer
There is a similar question How can I assign the result of a subroutine
How can I write a query similar to this one in LINQ to SQL
Can XMPP be applied in a similar way to the reverse Ajax pattern? Can
Can I use generateDS.py in python in a similar way that I would use
just wondering: in CSS I can access a div through #display div is there
there are similar questions but not clear answer around using sqlite db from multiple
In Java you can access variables in a class by using the keyword this
I want to create a set of classes that are very similar and can

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.