1 package demo.ws_rm.client; 2 3 import java.io.File ; 4 import java.lang.reflect.UndeclaredThrowableException ; 5 import javax.xml.namespace.QName ; 6 7 import org.objectweb.hello_world_soap_http.Greeter; 8 import org.objectweb.hello_world_soap_http.SOAPService; 9 10 11 public final class Client { 12 13 private static final QName SERVICE_NAME = 14 new QName ("http://objectweb.org/hello_world_soap_http", "SOAPService"); 15 private static final String USER_NAME = System.getProperty("user.name"); 16 17 18 private Client() { 19 } 20 21 public static void main(String args[]) throws Exception { 22 if (args.length == 0) { 23 System.out.println("please specify wsdl"); 24 System.exit(1); 25 } 26 27 try { 28 File wsdl = new File (args[0]); 29 SOAPService service = new SOAPService(wsdl.toURL(), SERVICE_NAME); 30 Greeter port = service.getSoapPort(); 31 32 for (int i = 0; i < 4; i++) { 34 System.out.println("Invoking sayHi..."); 35 String resp = port.sayHi(); 36 System.out.println("Server responded with: " + resp + "\n"); 37 38 System.out.println("Invoking greetMeOneWay..."); 39 port.greetMeOneWay(USER_NAME); 40 System.out.println("No response as method is OneWay\n"); 41 } 42 43 Thread.sleep(30 * 1000); 45 } catch (UndeclaredThrowableException ex) { 46 ex.getUndeclaredThrowable().printStackTrace(); 47 } catch (Exception ex) { 48 ex.printStackTrace(); 49 } finally { 50 System.exit(0); 51 } 52 } 53 } 54 | Popular Tags |