client.java

来自「基于eclipse环境下开发的cxf例程」· Java 代码 · 共 59 行

JAVA
59
字号
package demo.hw.client;import java.io.File;import java.net.URL;import javax.xml.namespace.QName;import org.apache.hello_world_soap_http.Greeter;import org.apache.hello_world_soap_http.SOAPService;public final class Client {    private static final QName SERVICE_NAME         = new QName("http://apache.org/hello_world_soap_http", "SOAPService");    private Client() {    }     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.toURL();        } else {            wsdlURL = new URL(args[0]);        }                System.out.println(wsdlURL);        SOAPService ss = new SOAPService(wsdlURL, SERVICE_NAME);        Greeter port = ss.getSoapPort();        String resp;         System.out.println("Invoking greetMe...");        resp = port.greetMe("Aihu");        System.out.println("Server responded with: " + resp);        System.out.println();        System.out.println("Invoking greetMe with invalid length string, expecting exception...");        try {            resp = port.greetMe("Invoking greetMe with invalid length string, expecting exception...");        } catch (Exception e) {            System.out.println("Expected exception has occurred: " + e.getMessage());        }        System.out.println();              System.exit(0);     }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?