Hi there,

I am trying to catch an AxisFault. I am able to get the SOAPFault from
the SOAPBody. But, when I am trying to get the SOAPDetail from the
SOAPFault, I am getting null. (please see the inline comments). Could
you please point out why I am getting the detail as null.

Your help will be greatly appreciated.

Thanks,
chil.


try {
       Call lastCall = locator.getCall();
       SOAPEnvelope env = lastCall.getResponseMessage().getSOAPEnvelope();

       if(env == null){
               logger.info("env is null");
       }
       logger.info("after env");
       Detail detail = null;
       SOAPBody sBody = null;
       SOAPFault sFault = null;

       try{
               sBody = env.getBody();
               if(sBody == null){
                       logger.info("sBody is null");
               }else{
                       logger.info("sBody is not null");
                       logger.info("sBody: ");
                       logger.info(sBody.toString());
               }
       }catch(Exception ee){
               logger.info("Catching exception in body block: ");
               ee.printStackTrace();
       }

       try{
               sFault = sBody.getFault();
               if(sFault == null){
                       logger.info("sFault is null");
               }else{
                       logger.info("sFault is not null");
                       logger.info("sFault is : ");
                       logger.info(sFault.toString()); // prints the
sFault with the detail in it.
               }
       }catch(Exception ee){
               logger.info("Catching exception in fault block: ");
               ee.printStackTrace();
       }

       try{
               detail = sFault.getDetail();
               if(detail == null){
                       logger.info("detail is null"); // prints
this... saying that the
detail is null
               }else{
                       logger.info("detail is not null");
               }
       }catch(Exception ee){
               logger.info("Catching exception in detail block: ");
               ee.printStackTrace();
       }

       logger.info("after detail");

       Iterator it = detail.getDetailEntries();
       while(it.hasNext()){
               ErrorMessageType errorMsg = (ErrorMessageType)it.next();
               logger.info("after Errormsg");
               StatusType status = new StatusType();
               logger.info("Error Code from Vendor: " +
errorMsg.getErrorCode());
               String errorCode =
convertToOurErrorCode(errorMsg.getErrorCode());
               logger.info("Our Error Code: " + errorCode);
               status.setCode(errorCode);
               status.setDescription("FAILURE");
       }
} catch (Exception e1) {
       logger.info("Printing SOAPException");
       e1.printStackTrace();
}

Reply via email to