afunms

My Software,My Dream—Forge a more perfect NMS product.

第一个SOAP程序

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

posted on 2007-07-22 19:50 afunms 阅读(194) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

News

留言簿(18)

随笔档案

相册

搜索

最新评论

阅读排行榜