|
Hello.jws:
public class Hello
{
public String hello(String name)
{
return name + "welcome to axis!";
}
}
WebServiceClient.java:
package coffee;
import org.apache.axis.client.*;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class WebServiceClient
{
public static void main(String args[])
{
System.out.println("开始调用WebService");
try
{
String endpoint = "http://localhost:8209/axis/Hello.jws";
Service service = new Service();
Call call = (Call)service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName("hello");
String s = (String)call.invoke(new Object[] {"coffee"});
System.out.println(s);
}
catch (Exception e)
{
System.out.println(e.toString());
}
System.out.println("调用WebService正常结束");
}
} |
|