Web Services client example
Note: This article is taken from Axis User's Guide on Apache's public AXIS server, you send a string to the service, which can return the same string to you. Below we write a Web Services client example Calling this service: 1 import org.apache.axis.client.call; 2 import org.apache.axis.client.service; 3 Import javax.xml.namespace.qname; 4 5 public class testclient {6 public static void main String [] args) {7 try {8 string endpoint = 9 "http://nagoya.apache.org:5049/axis/services/echo";10 // Create two JAX-RPC object 11 service service = new service (); 12 Call call = (call) service.createCall (); 13 // SOAP message Destination 14 Call.SetTargetendPointDress (new java.net.url (endpoint)); // To call the action name 15 Call. Setoperationname ("http://soapinterop.org/", "echostring")); 16 // Introducing parameter 17 String Ret = (String) Call.Invoke (new object [] {"Hello! "}); 18 19 System.out.Println (" Sent 'Hello!', GOT '" RET "' "; 20} cat CH (Exception E) {21 System.err.Println (E.TOString ()); 22} 23} 24} The above files on the D: / Axis / Axis-1_1 / Samples / UserGuide / Example1 directory of AXIS.
Join the needs of the package, connect to the network, run the program, you will get the following results: Sent 'Hello!', Got 'Hello!'