Hi,
i am trying to handle HTTP (transport) errors with Axis, something
like this code i show below, so i could manage authentication problems
and other stuff. I can't find a way to get the AxisFault object from
my code generated by WSDL2Java, i see nothing in my code that could
return an AxisFault object. How can i reach to it?
what i want to do..:
public void printAxisFault(AxisFault x)
{
if(x.getFaultCode().equals(new QName("http://xml.apache.org/axis/","HTTP")))
{
Element e =
x.lookupFaultDetail(
new QName("http://xml.apache.org/axis/","HttpErrorCode"));
if(null != e)
{
e.normalize();
String httpErrorCode = e.getFirstChild().getNodeValue().trim();
if(httpErrorCode.equals("407"))
System.out.println("Proxy password incorrect");
else if(httpErrorCode.equals("502") || httpErrorCode.equals("504"))
System.out.println("Proxy cannot find the server");
else if(httpErrorCode.equals("500"))
System.out.println("Proxy or server unavailable");
else if(httpErrorCode.equals("404"))
System.out.println("No Web service (404 File Not Found)");
else
System.out.println(x.getFaultString());
}
else
System.out.println("Network error: " + x.getFaultString());
}
else if(x.getFaultCode().equals(
new QName("http://schemas.xmlsoap.org/soap/envelope/",
"Server.userException")))
System.out.println("Most likely a net error: " + x.getFaultString());
else
System.out.println("SOAP Fault: " + x.getFaultCode() + ", "
+ x.getFaultString());
}
currently i want to apply it to this small example for a web server
that ask me for basic authentication credentals, it works currently,
but i want to control dinamically when to send credentials (if error
401 ocurrs then i could retry sending credentials).
public static void main (String[] args) {
try {
EchoImpServiceLocator sl = new EchoImpServiceLocator ();
EchoImp service = sl.getEcho ();
((EchoSoapBindingStub) service).setUsername ("demian");
((EchoSoapBindingStub) service).setPassword
("demianapache");
System.out.println ("Invoking remote method...");
System.out.println (service.echo ("Hola amigo!"));
} catch (ServiceException se) {
System.err.println ("Error: " + se.getMessage ());
} catch (RemoteException re) {
System.err.println ("Error: " + re.getMessage ());
}
}
thanks!
--
Jonathan J. Vargas Rodriguez
[EMAIL PROTECTED]
"Conservar el silencio interior cuando vuelo en la tormenta me es
mejor, porque asi ya no soy otra gota de la tempestad"