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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:08:40+00:00 2026-05-12T11:08:40+00:00

Im using the standard java ws implementation shipped with e.g. java6 (javax.jws.*). I have

  • 0

Im using the standard java ws implementation shipped with e.g. java6 (javax.jws.*).

I have the following:

import javax.jws.*;


@WebService(name="Widget")
public interface Widget {
    @WebMethod
    public @WebResult String getGadget(@WebParam(name = "id") long id) throw MyOwnException;    
}

Is this possible? Do I have to annotate MyOwnException with e.g the @WebFault annotation?
During my initial tests I also noticed that, on the client side, the autogenerated MyOwnException was renamed to MyOwnException_Exception and wrapped the “original” MyOwnException.

Or if this is a bad idea, are there any recommended Exceptions to throw from a webservice like this?

  • 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-12T11:08:41+00:00Added an answer on May 12, 2026 at 11:08 am

    Don’t rely on auto generated exceptions across service boundaries! Do use the @WebFault annotation you were considering. If the client will ever need to deal with it, there is nothing exceptional about it. Make it part of your data contract(Fault Contract). Google “SOAP fault element” there are tutorials and other articles explaining how and why.

    The normal control flow in the service should deal with fault situations… faults are not necessarily exceptional.

    When it comes to throwing exceptions here are some great “almost” rules for exceptions (of course there are exceptions to these rules):

    Almost Rule #1

    When deciding if you should throw an
    exception, pretend that the throw
    statement makes the computer beep 3
    times, and sleep for 2 seconds. If
    you still want to throw under those
    circumstances, go for it.

    Almost Rule #2

    If you think it will be at all normal
    for anyone to want to catch your
    exception, then probably it shouldn’t
    be an exception at all.

    When you apply these to a service request/exchange you see that it really doesn’t make sense to think in terms of exceptions coming back to the caller. If the caller is ever going to be told about a problem, there is nothing truly exceptional about the problem at that point, and it should be handled by the service contract.

    Even if you just have one fault contract that says “the request failed for an unknown reason” the client can anticipate that and it becomes part of the contract. If you want to get more detailed as necessary, it might be helpful depending on your requirements.

    Think of the REST service architecture. Http returns a handful of pre-defined error codes. There are just enough different error categories that the client can take appropriate action for each… give-up because the resource (page) is gone permenantly, redirect because the page has moved, retry because there was an internal server error, deal with user for permissions required, etc. As a general http client, you wouldn’t expect to see internal language exceptions come back and mean anything to you. There are dozens of languages, and thousands of potential exceptions in existing http service implementations. That’s why they aren’t part of the contract.

    Hopefully that helps explain why your faults are not exceptional, and why the should be an explicit part of the contract.

    Good luck-

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

Sidebar

Ask A Question

Stats

  • Questions 161k
  • Answers 161k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Atlast I came up with a new activate_plugin function that… May 12, 2026 at 11:53 am
  • Editorial Team
    Editorial Team added an answer Since StringBuilder provides both indexOf(String,int) and replace(int,int,String) one can easily… May 12, 2026 at 11:53 am
  • Editorial Team
    Editorial Team added an answer Look at quirksmode.org You should consider buying his (PPK's) book… May 12, 2026 at 11:53 am

Related Questions

I'm already familiar with the standard Java package naming convention of using a domain
I'm using Eclipse Ganymede to create a web application, but the project's currently just
I'm using Hibernate's implementation of JPA. My Maven pom.xml references hibernate-entitymanager . My question
I'm using java and referring to the double datatype. To keep it short, I'm
Greetings, I'm using embedded java, I write the application to a low resource device.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.