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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:07+00:00 2026-05-26T16:20:07+00:00

I have developed a webservice using Apache CXF ,which will be in production very

  • 0

I have developed a webservice using Apache CXF ,which will be in production very soon .
I am concerned about the exception handling in this , i am not sure whether what i followed is correct or not .

I have a method shown below which i exposed i as a webservice

import javax.jws.WebService;

@WebService
public interface TataWebService {
    public String distragery()throws Exception;

}
public String distrager throws Exception {
    int a  = 30;
    strategyData = "currentlyhadcoced" ;

    if(a==30) {
        throw new IncorrectProjectIdsException("The Value of a is 30");
    }

    return strategyData;
}

And the way i defined User defined exception is this way

@WebFault(name = "IncorrectProjectIdsDetails")    
public class IncorrectProjectIdsException extends Exception {

    private java.lang.String incorrectProjectIdsDetails;

    public IncorrectProjectIdsException (String message) {
        super(message);
    }

    public java.lang.String getFaultInfo() {
        return this.incorrectProjectIdsDetails;
    }
}

Please tell me if this is correct , regarding the throws declaration inside the method signature or shuld we handle in any other manner ??

Thank you very much

  • 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-26T16:20:08+00:00Added an answer on May 26, 2026 at 4:20 pm

    You should throw the specific subclass of Exception in your interface that’s annotated with @WebService so that the JAX-WS engine knows to publish the information about which faults are possible. That’s because that is information that is discovered statically by examining the declarations, not by dynamic discovery of the exceptions that are actually thrown.

    If you’re stuck with a lower-level API that can throw anything (it happens; indeed, it happens a lot) then you should wrap that lower-level exception. Here’s a simple way of doing that:

    @WebFault(name = "ImplementationFault")    
    public class ImplementationException extends Exception {
        public ImplementationException(Exception cause) {
            super(cause.getMessage(), cause);
        }
    }
    

    Which you’d use like this inside your web method:

    public String fooMethod(String example) throws ImplementationException {
        try {
            return doRealThingWith(example);
        } catch (Exception e) {
            throw new ImplementationException(e);
        }
    }
    

    (There are other ways of doing the exception mapping, but they’re quite a lot more complex. Wrapping is at least easy.)

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

Sidebar

Related Questions

I have developed a WebService which will be accessed by 1000's of users at
We have developed a webservice based on Apache CXF . This is working fine
I have developed a web app using a webservice. Everything works fine in the
I have created a web service which has a couple of methods developed using
We have developed a web application which consumes a web service. The user will
I have developed a web service(using ruby/sinatra/sqs) which runs on Linux Red Hat. I
We have developed a RESTful webservice using the restlet framework. The service is called
I have developed a Webservice using Axis2 , made a .aar file from it
I have developed a simple Apache-Axis java web service using Eclipse IDE and now
I have developed webservices using CXF framework. We are exposing all our Database operation(Service

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.