There is a great article by Eben Hewitt that helped us deal with this in a standard way... perhaps this will help:
http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-exceptions-in-java-jaxws-web-services.html On Tue, Mar 20, 2012 at 4:41 PM, Barry Hathaway <[email protected]>wrote: > I'm having a problem getting my custom exceptions to map to something > other than SOAPFaultExceptions. > Being kind of a newbie I'm sure it is something simple. > > In my service interface I have: > > @WebMethod(operationName="**getUniqueInstanceUri", action="urn:** > getUniqueInstanceUri") > public String getUniqueInstanceUri(@**WebParam(name="namespace")**String > namespace, > @WebParam(name="baseLocalName"**)String > baseLocalName) > throws com.ge.research.sadl.**sadlserverplus.** > InvalidNameException, > com.ge.research.sadl.**sadlserverplus.** > SessionNotFoundException; > > where InvalidNameException was generated from the WSDL and looks like: > > @WebFault(name = "InvalidNameFault", targetNamespace = " > http://sadlserverplus.sadl.**research.ge.com<http://sadlserverplus.sadl.research.ge.com> > ") > public class InvalidNameException extends Exception { > > private com.ge.research.sadl.**sadlserverplus.**InvalidNameFault > invalidNameFault; > > public InvalidNameException() { > super(); > } > ........... other standard methods > } > > In the service implementation I throw InvalidNameException and it appears > to get thrown correctly > Now in my client I try to catch it; however, I am not able to do so. > Instead I have to catch SOAPFaultException. > My client, generated from the WSDL, looks like: > > private static final QName SERVICE_NAME = new QName(" > http://sadlserverplus.**sadl.research.ge.com<http://sadlserverplus.sadl.research.ge.com>", > "SadlServicePlus"); > SadlServicePlus_Service ss; > SadlServicePlus port; > URL wsdlURL = new URL(url + "?wsdl"); > this.ss = new SadlServicePlus_Service(**wsdlURL, SERVICE_NAME); > this.port = ss.getSadlServicePlusPort(); > ((BindingProvider)this.port).**getRequestContext().put(** > BindingProvider.SESSION_**MAINTAIN_PROPERTY,Boolean.**TRUE); > try { > return port.getUniqueInstanceUri(**namespace, baseLocalName); > } catch (com.ge.research.sadl.**sadlserverplus.**InvalidNameException > e) { > System.out.println("never reached"); > } catch > (com.ge.research.sadl.**sadlserverplus.**SessionNotFoundException > e) { > System.out.println(e.**getMessage()); > } > > Any idea what I am doing wrong that is causing the exception not to get > marshalled/unmarchalled correctly? > Thanks. > > Barry Hathaway > > *Mark *
