Wonderful. getCause().getMessage() returns the http exception. -----Original Message----- From: Daniel Kulp [mailto:[email protected]] Sent: Thursday, May 19, 2011 7:52 PM To: [email protected] Cc: Madhav Vodnala Subject: Re: catching/handling HTTP exceptions
Most likely, if you grab the "cause" of the WebServiceException, it would be the HTTPException you want. Dan On Wednesday, May 18, 2011 9:21:28 PM Madhav Vodnala wrote: > I see this error in the log4j log file. > > > > Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response > '401: Unauthorized' when communicating with > http://10.107.172.79/test/_vti_bin/lists.asmx > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRe > sp > onseInternal(HTTPConduit.java:1502) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRe > sp > onse(HTTPConduit.java:1448) > > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HT > TP > Conduit.java:1356) > > at > org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56 > ) > > at > org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:614) > > at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndin > gI > nterceptor.handleMessage(MessageSenderInterceptor.java:62) > > ... 9 more > > > > Only javax.xml.ws.WebServiceException with "Could not send Message." > message is thrown while calling the service > > try{ > > GetListCollectionResult result = port.getListCollection(); > > }catch (javax.xml.ws.WebServiceException excep){ > > } > > > > How/where can we catch the actual HTTP exception/error. I kind of > followed the Interceptor/MessageObserver concept but could not capture > the HTTP error using them. > > > > > > This is how we call the service. > > > > To provide NTLM credentials: > > > > Authenticator.setDefault( extended class of Authenticator); > > > > Create the service. > > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > > factory.setServiceClass(ListsSoap.class); > > factory.setAddress(list_url); > > ListsSoap port = (ListsSoap) factory.create(); > > > > Update the conduit. > > .. > > Client client = ClientProxy.getClient(port); > > > > HTTPConduit http = (HTTPConduit) client.getConduit(); > > > > HTTPClientPolicy httpClientPolicy = new > HTTPClientPolicy(); > > httpClientPolicy.setConnectionTimeout(36000); > > httpClientPolicy.setAllowChunking(false); > > http.setClient(httpClientPolicy); > > > > Call service and get the result. > > > > GetListCollectionResult result = port.getListCollection(); > > > > .. > > And finally close the conduit. > > > > http.close(); -- Daniel Kulp [email protected] http://dankulp.com/blog Talend - http://www.talend.com
