Skip to content

Instantly share code, notes, and snippets.

@maxisoft
Last active November 9, 2015 15:34
Show Gist options
  • Save maxisoft/b26d7d542370ed2d7899 to your computer and use it in GitHub Desktop.
Save maxisoft/b26d7d542370ed2d7899 to your computer and use it in GitHub Desktop.
package org.examples;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.io.IOException;
import java.net.*;
import java.util.ArrayList;
import java.util.List;
public class Client2 {
public static class MyProxySelector extends ProxySelector {
@Override
public List<Proxy> select(URI uri) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", 3128));
ArrayList<Proxy> list = new ArrayList<Proxy>();
list.add(proxy);
return list;
}
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
System.err.println("Connection to " + uri + " failed.");
}
}
public static void main(String... args) throws MalformedURLException, DuplicateException_Exception {
ProxySelector.setDefault(new MyProxySelector());
String namespace = "http://examples.org/";
String endpoint = "http://127.0.0.1:9999/ws/contact-book?wsdl";
String op = "ContactBookImplService";
QName qName = new QName(namespace, op);
Service service = Service.create(new URL(endpoint), qName);
ContactBook helloWorld = service.getPort(ContactBook.class);
helloWorld.addContact("toto", "toto@dumb.mail");
System.out.println(helloWorld.listContacts());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment