Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D921C10666 for ; Fri, 20 Sep 2013 12:47:30 +0000 (UTC) Received: (qmail 39798 invoked by uid 500); 20 Sep 2013 12:47:26 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 39592 invoked by uid 500); 20 Sep 2013 12:47:25 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 39574 invoked by uid 99); 20 Sep 2013 12:47:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 12:47:22 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ashakirin@talend.com designates 64.95.72.241 as permitted sender) Received: from [64.95.72.241] (HELO mxout.myoutlookonline.com) (64.95.72.241) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 12:47:15 +0000 Received: from mxout.myoutlookonline.com (localhost [127.0.0.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 8227541696C for ; Fri, 20 Sep 2013 08:46:54 -0400 (EDT) X-Virus-Scanned: by SpamTitan at mail.lan Received: from S10HUB003.SH10.lan (unknown [10.110.2.1]) by mxout.myoutlookonline.com (Postfix) with ESMTP id 2E87C4168B7 for ; Fri, 20 Sep 2013 08:46:54 -0400 (EDT) Received: from S10BE002.SH10.lan ([::1]) by S10HUB003.SH10.lan ([::1]) with mapi id 14.01.0379.000; Fri, 20 Sep 2013 08:46:53 -0400 From: Andrei Shakirin To: "users@cxf.apache.org" CC: "mandys.inbox@gmail.com" Subject: RE: How to handle exceptions from a SOAP webservice in a single point Thread-Topic: How to handle exceptions from a SOAP webservice in a single point Thread-Index: AQHOtXrEKjhbnlsbZUGCRuismr0ER5nNzwgAgAAKU4CAALmHUA== Date: Fri, 20 Sep 2013 12:46:53 +0000 Message-ID: References: <523B6642.8060305@gmail.com> <78FFB0F9-8F0A-44C5-B256-063C8295DB65@gmail.com> In-Reply-To: <78FFB0F9-8F0A-44C5-B256-063C8295DB65@gmail.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [178.2.130.62] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Hi, Regarding the first question you can do something like: fault =3D (SOAPFactory.newInstance()).createFault(); fault.setFaultString(BUSINESS_FAULT_STRING); String errorString =3D businessException.getMessage(); try { // 2. Parse exception string and add it as SOAPFault Details Document faultDoc =3D builder.parse(new ByteArrayInputStream( errorString.getBytes())); Detail detail =3D fault.addDetail(); Document owner =3D detail.getOwnerDocument(); Node details =3D owner.importNode(faultDoc.getDocumentElement(), true); detail.appendChild(details); } catch (SAXException e) { // 3. If exception string is not XML, set is as fault string fault.setFaultString(errorString); } return new SOAPFaultException(fault); Regards, Andrei. > -----Original Message----- > From: Mandy Warren [mailto:mandys.inbox@gmail.com] > Sent: Donnerstag, 19. September 2013 23:39 > To: users@cxf.apache.org > Subject: Re: How to handle exceptions from a SOAP webservice in a single > point >=20 > Many thanks again for such a fast reply! So I have written an > AbstractSoapInterceptor and managed to retrieve the exception from the > message via >=20 > Exchange exchange =3D message.getExchange; >=20 > exchange.get(Exception.class); >=20 > Pls can you explain how I then create a Fault with the info I want and se= nd it > back? >=20 > Also because I want to use local transport I was looking at using > SOAPHandlers instead of in interceptors to pull out some header info I ne= ed, > is there a way to get / change the exception info from the handler instea= d of > via an interceptor? >=20 > Many thanks >=20 > Sent from a mobile device >=20 > On 19 Sep 2013, at 22:01, Sergey Beryozkin wrote: >=20 > > Hi > > On 19/09/13 21:56, Mandy Warren wrote: > >> Hi, > >> > >> I would like to handle all exceptions thrown by my webservice in a > >> single point so I can create Faults with specific codes / strings > >> based on info in the exception. When using JAX-RS I can do this very > >> neatly via an Exception Mapper (and then convert to a REST response) > >> but there doesn't seem to be an equivalent for JAX-WS.. > >> > >> Is there a way to handle the exceptions before they are turned into > >> SOAP Faults? > > See > > > > http://cxf.547215.n5.nabble.com/Implementing-smarter- > RuntimeException- > > handling-for-JAX-WS-service-tt5734264.html > > > > HTH > > Sergey > >> Many thanks > >> Mandy > >