I keep returning to the same problem of trying to find a way of allowing a user on the client side to determine proxy settings. It seems if they define:


  System.setProperty("proxySet", "true" );
  System.setProperty("http.proxyPort",8080);
  System.setProperty("http.proxyHost",wwcache.blah);

before the first call is invoked it works. The problem comes when the wrong proxy settings are given and the exception is caught. If the correct proxy settings are then tried and a second call made to the server then it fails with the same exception (java.net.UnknownHostException).

The example below demonstrates this problem. If this is run with:

java -Dhttp.proxyPort=8080 -Dhttp.proxyHost=wwwcache HelloClient

then it returns:

java.net.UnknownHostException: wwwcache
java.net.UnknownHostException: wwwcache


If the comments are taken out from this example in the main routine then It connects to the server & a response is given.Anyone know what is going on here?


Thanks!
Tim


import org.apache.axis.client.Call; import org.apache.axis.client.Service; import javax.xml.namespace.QName;

public class HelloClient {

public HelloClient() {

      try {
            String endpoint =
                     "http://localhost:8080/axis/services/HelloServer";;

            Service  service = new Service();
            Call     call    = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName("http://localhost:8080/";, "hello"));


String ret = (String) call.invoke(new Object[] { "Hello!"});

            System.out.println("Sent 'Hello!', got '" + ret + "'");
        }
       catch (Exception e) {
            System.err.println(e.toString());
       }
    }

public static void main(String [] args) {

// System.setProperty("proxySet", "true" ); //works if proxy set before Call
// System.setProperty("http.proxyPort","");
// System.setProperty("http.proxyHost","");
new HelloClient();
System.setProperty("proxySet", "true" );
System.setProperty("http.proxyPort","");
System.setProperty("http.proxyHost","");
new HelloClient();
}
}




_________________________________________________________________
Surf together with new Shared Browsing http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059




Reply via email to