Exemplo n.º 1
0
  public static void main(String args[]) {
    try {

      SpringBusFactory bf = new SpringBusFactory();
      URL busFile = Client.class.getResource("/client.xml");
      Bus bus = bf.createBus(busFile.toString());
      BusFactory.setDefaultBus(bus);

      SOAPService service = new SOAPService();
      Greeter port = service.getSoapPort();

      System.out.println("Invoking sayHi...");
      String resp = port.sayHi();
      System.out.println("Server responded with: " + resp + "\n");

      System.out.println("Invoking greetMe...");
      resp = port.greetMe(USER_NAME);
      System.out.println("Server responded with: " + resp + "\n");

      System.out.println("Invoking greetMeOneWay...");
      port.greetMeOneWay(USER_NAME);
      System.out.println("No response from server as method is OneWay\n");

      try {
        System.out.println("Invoking pingMe, expecting exception...");
        port.pingMe();
      } catch (PingMeFault ex) {
        System.out.println("Expected exception occurred: " + ex);
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      System.exit(0);
    }
  }
Exemplo n.º 2
0
  public static void main(String args[]) throws Exception {

    if (args.length == 0) {
      System.out.println("please specify wsdl");
      System.exit(1);
    }

    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
      wsdlURL = wsdlFile.toURI().toURL();
    } else {
      wsdlURL = new URL(args[0]);
    }

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = Client.class.getResource("/ClientConfig.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);

    System.out.println(wsdlURL);
    SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);
    Greeter port = ss.getPort(PORT_NAME, Greeter.class);

    System.out.println("Invoking greetMe...");
    try {
      String resp = port.greetMe(System.getProperty("user.name"));
      System.out.println("Server responded with: " + resp);
      System.out.println();

    } catch (Exception e) {
      System.out.println("Invocation failed with the following: " + e.getCause());
      System.out.println();
    }

    System.exit(0);
  }