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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:33:41+00:00 2026-05-16T16:33:41+00:00

Application configuration: Web application using java first method of creating JAX-WS 2.0 Web Services

  • 0

Application configuration:

  • Web application using java first method of creating JAX-WS 2.0 Web Services with annotations.
  • WebLogic 10.3

My Requirements

The requirements I have are to deploy a single web service implementation class, but change logic based on the URL from which the service was accessed.

Question:
I’m assuming a good way to do this is to deploy different mappings in web.xml and initialize them with different parameters. Is there a better way?

What is the best way to switch logic off the URL from which the web service was accessed? Should I try to configure two servlet mappings in web.xml with initialization parameters (tried, but couldn’t get it to work), or should I parse the URL in the service impl? Any other alternatives?

What I’ve Tried (but didn’t work)

I have tried adding the <init-param> in the <servlet> element in web.xml. However, can’t get to the ServletConfig object inside the web service to retrieve the param. The web service does not have all the functionality of a standard Servlet (even if I implement Servlet or ServletContextListener). I only have access to the WebServiceContext (it seems) and from there I can only get <context-param> elements–but I would need <init-param> elements instead.

In web.xml, I enter two <servlet> elements using the same Java class, but which map to two different URLs as follows. Notice how the “source” param is different in each Servlet mapping.

<servlet>
    <servlet-name>Foo</servlet-name>
    <servlet-class>com.Foo</servlet-class>
    <init-param>
        <param-name>source</param-name>
   <param-value>1</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Foo</servlet-name>
    <url-pattern>/Foo</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>Bar</servlet-name>
    <servlet-class>com.Foo</servlet-class>
   <init-param>
        <param-name>source</param-name>
   <param-value>2</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Bar</servlet-name>
    <url-pattern>/Bar</url-pattern>
</servlet-mapping>  
  • 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-16T16:33:41+00:00Added an answer on May 16, 2026 at 4:33 pm

    You very well may have, but did you try using MessageContext at runtime to determine what the source is?

    @WebService
    public class CalculatorService implements Calculator
    {
    
        @Resource
        private WebServiceContext context;
    
        @WebMethod
        public void getCounter()
        {
            MessageContext mc = wsContext.getMessageContext();
            // you can grab the HttpSession
            HttpSession session = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
            // ...or maybe the path info is enough
            String path = mc.get(MessageContext.PATH_INFO);
            // the query itself should almost definitely be enough
            String query = (String) mc.get(MessageContext.QUERY_STRING);
        }
    
    }
    

    I got the idea from http://sirinsevinc.wordpress.com/category/jaxws/. Haven’t tried it, though.

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

Sidebar

Related Questions

I am using Orion server for my Java-based web application. I have a run
I have a web application deployed in WebLogic. In one of my java file,
I have created a simple java web (Vaadin) application project using JPA and it
I am creating a Java application where I am using log4j. I have given
I have developed a first web application using a local PostgreSQL 9.1 on OSX
I have a web application with over 200 configuration settings. These control everything from
I have a web application that dynamically loads assemblies based on database configuration entries
By default configuration in a new workspace I have Run as Web Application in
I have a Java web application leveraging JPA. The database instance is specified in
I have a Java EE 6 Wicket application deployed with maven using IntelliJ IDEA

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.