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

  • SEARCH
  • Home
  • 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 4320844
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:40:41+00:00 2026-05-21T08:40:41+00:00

I have a simple web service like this: @WebService public class MyWebService { @WebMethod

  • 0

I have a simple web service like this:

@WebService
public class MyWebService 
{
    @WebMethod
    public String ProcessQuery(@WebParam(name="query") String q)
    {
    // Logging here: User IP, etc.
    }

    public static void main(String[] args) throws Exception 
    {
    String address = "http://127.0.0.1:8023/_WebServiceDemo";
    Endpoint.publish(address, new MyWebService());
    new DocumentServer();
    System.out.println("Listening: " + address);
    }
}

I want to add a logging method for my service to extract information. I’ve heard about NCSA format and Log4J but I don’t know how to use them in the service. I want to log user’s ip and other info. How can I do it?

Thanks.

Edit: I should note that the main part of my question is how can I retrieve some data such as user’s IP, client, etc. in the web method.

  • 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-21T08:40:42+00:00Added an answer on May 21, 2026 at 8:40 am

    Add WebServiceContext to your class, so you can get the HttpServletRequest:

    @WebService
    public class MyWebService 
    {
        @Resource
        WebServiceContext wsContext;
    
        @WebMethod
        public String ProcessQuery(@WebParam(name="query") String q)
        {
            MessageContext messageContext = wsContext.getMessageContext();
            HttpServletRequest request = (HttpServletRequest) messageContext.get(SOAPMessageContext.SERVLET_REQUEST);
    
            // now you can get anything you want from the request
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
I have a web service that's pretty simple; something like this: public class LeadService
Well im trying a simple i have a simple web service like page containing
Hello I have a simple wcf service like this, with a test method which
I have a simple web service method that returns a simple java class as
I have a simple web service call, generated by a .NET (C#) 2.0 Windows
I have a simple web service that uses an oracle database. When I test
I have a simple web service that has an API third party developers are
I have a simple WCF Web service. It's hosted on IIS under the default
I have created a simple web-service using Java. i want to load jars related

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.