Re: Accessing faultstring in Axis2 client

Jack Sprat <[email protected]>
Newsgroups gmane.text.xml.axis.user
Message-ID <[email protected]>
Thanks for the reply but, again, the AxisFault is not available here.  Here is the code snippet again.

try{
  stub.getPublication(pub, auth);
} catch(PublicationException pe) {
// AxisFault is not available here!
}

Thanks,
J  


On Friday, June 6, 2014 6:30 AM, satyapriya sahoo <[email protected]> wrote:



I think the bellow code will help you.


try{
  //Client code  
}catch(AxisFault af){
   if(af!=null){
         RemoteException re = af; 
         Throwable th = re.detail;

         String faultMsg  = th.toString(); 
         System.out.println("FaultString :: "+faultMsg  );
  }
}

I know this is not easy, may bellow methods help to solve your problem
                        af.getFaultAction()
af.getFaultRole()
af.getMessage()
af.getReason() 
Thanks,
Satya



On Thu, Jun 5, 2014 at 7:13 PM, Jack Sprat <[email protected]> wrote:

There is a method in the Exception class named #getFaultMessage.  This returns blank, which is correct since there is no text in the exception.  It would be very easy if this was the answer.
>
>I need to get the faultstring.  The faultstring is outside the exception.  See the XML snippet below. 
>
>I'm working on a different way of sending the request and capturing the response.  There is a lot more coding involved but appears to be the only way to get the faultstring element.
>
>Thanks,
>J
>
> 
>
>
>
>On Thursday, June 5, 2014 2:37 AM, satyapriya sahoo <[email protected]> wrote:
> 
>
>Jack,
>  
>Hope bellow points will help you to solve your Problem.
>
>You can process in 3 ways.
>
>
>1) IN your client code you need an catch block for AxisFault and U need to retrieve the message from that exception 
>try{
>  //Client code 
>}catch(AxisFault af){
>   if(af!=null){
>         String faultMsg =  af.getMessage();
>         System.out.println("FaultString :: "+faultMsg  ); 
>  }
>}
>
>
>2) If it is coming as a string, then you can do some String operation.
>
>
>3) You can also take the help of dom parser or sax parse to retrieve the specific value, because it is coming as a xml format.
>
>
>Thanks,
>Satya
>
>       
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.