You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Jonathan J. Vargas R." <jo...@gmail.com> on 2005/08/09 07:39:37 UTC

Handling HTTP Errors

hi, 

how can i handle HTTP errors? 

my practice will be for "Error (401) Authorization 
required", so i can catch this and do something like.. display a
dialog prompting for a
username and password and then retry the connection with supplied credentials.

i want to apply it to this class, for example:


public class Main {
    public static void main (String[] args) {
	try {
	    EchoImpServiceLocator sl = new EchoImpServiceLocator ();
	    EchoImp service = sl.getEcho ();

	    ((org.apache.axis.client.Stub) service).setUsername ("anyuser");
	    ((org.apache.axis.client.Stub) service).setPassword ("anypassword");
	    
	    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 ());
	}
    }
}

in this case the client will always supply  username and password, by
I want to control this, just for those sites or users that require
authentication by the server, and then prompt the user for them.

thanks.


-- 
Jonathan J. Vargas Rodriguez
jonathan.j.vargas@gmail.com
"Conservar el silencio interior cuando vuelo en la tormenta me es
mejor, porque asi ya no soy otra gota de la tempestad"