thanks for the tip Steve - looks like this isnt just me so ive made it a bug report.
/tom -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 11:28 AM To: [EMAIL PROTECTED] Subject: Re: wsdl2java fault bug ? You need to hand modify the wsdl file so that the qname for each fault is different. The java2wsdl util creates the same qname for each fault. This name is used to lookup the fault from a map and hey presto only one id returned, generally the last fault specified. If you hand modify the wsdl file to give each fault a diffent qname (i use the scheme urn:<exceptionName> so in your situation I would change it to be urn:NoSuchUserFault. This has fixed all of my problems. It is very hard to find documentation on Axis fault handling as the person who wrote the documentation states that he to is unsure how the fault handling realy works. A lot of people do not seem to have this problem as they use standard java exceptions which are wrapped in a RemoteException. This does however make handling the exception more difficult at the client end. Regards Steve Quoting Silvano Maffeis <[EMAIL PROTECTED]>: > Yes, I just got that very same problem! I'm using axis-1_2RC1. > Any workarounds? (Well, besides resorting to using just one fault type, > of course 8-) > > silvano > > [EMAIL PROTECTED] wrote: > > >Anyone else observed that when you have code that throws multiple possible > >faults, the generated stub assumes that the fault is always the last > >defined ? > > > >in this case, if you throw SomeOtherFault and verify that the XML going > >over the wire correctly reflects the fault, client side it assumes the > >fault relates to NoSuchUserFault and inturn complains about missing > >faultcode (since its set for SomeOtherFault and not NoSuchUserFault since > >we didnt want to throw that) ? > > > >i.e > > > >oper.addFault(new org.apache.axis.description.FaultDesc( > >new javax.xml.namespace.QName("urn:userservice", "fault"), > >"com.mypackage.faults.SomeOtherFault", > >new javax.xml.namespace.QName("http://faults.mypackage.com", > >"ServerFault"), true)); > > > >oper.addFault(new org.apache.axis.description.FaultDesc( > >new javax.xml.namespace.QName("urn:userservice", "fault"), > >"com.mypackage.faults.NoSuchUserFault", > >new javax.xml.namespace.QName("http://faults.mypackage.com", > >"NoSuchUserFault"), true)); > > > >try > >{ > > // do stuff that might generate these exceptions > >} > >catch(NoSuchUserException nsue) > >{ > > throw new com.mypackage.faults.NoSuchUserFault(nsue.getUsername()); > >} > >catch(SomeOtherException soe) > >{ > > throw new com.mypackage.faults.SomeOtherFault(soe.getUsername()); > >} > > > >/tom > > > > > > > -- > Dr. Silvano Maffeis, Software Architect, Pyx Engineering AG Zurich > http://www.maffeis.com http://www.pyx.ch phone:+41-1-404-1006 > >
