我的第一個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();
}
}
}