我的第一个SOAP程序,这将成为我研究web service的开始
public class HelloClient
{
public String getName(String name)
{
return "你好" + name + ",欢迎来到Web服务的世界!";
}
}
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
import java.net.URL;
public class SayHelloClient
{
public static void main(String[] args)
{
try
{
String endpoint = "http://localhost:8080/axis/HelloClient.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName(endpoint,"getName"));
call.setTargetEndpointAddress(new URL(endpoint));
String ret = (String) call.invoke(new Object[]{"zhangsan"});
System.out.println("return value is:" + ret);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}