服務請求程式:ArithmClient

package com.emprogria; import java.net.URL; public class ArithmClient { /** * @param args 命令列參數 */ public static void main(String[] args) { String entryPoint = "127.0.0.1:8080"; int x = 0; int y = 0; // 自命令列讀取參數 if (args.length > 2) { entryPoint = args[0]; x = Integer.parseInt(args[1]); y = Integer.parseInt(args[2]); } try { // 取得 Web Service 介面 URL myURL = new URL("http://" + entryPoint + "/Arithm/ArithmWS?wsdl"); com.emprogria.ArithmWSService myService = new com.emprogria.ArithmWSService(myURL); com.emprogria.ArithmWS myPort = myService.getArithmWSPort(); int result = myPort.add(x, y); System.out.println("Result = " + String.valueOf(result)); } catch (Exception ex) { ex.printStackTrace(); } } }