happyfish

BlogJava 首页 新随笔 联系 聚合 管理
  38 Posts :: 1 Stories :: 62 Comments :: 0 Trackbacks
以下演示在J2SE 1.4.2 版本下访问Web
Service 的2 种方式。
Axis
需要下载axis, 地址为:http://apache.linuxforum.net/dist/ws/axis/1_1/axis-1_1-src.zip
代码如下:
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class t2 {
public static void main(String[] args) {
long time=System.currentTimeMillis();
try {
String endpoint="http://localhost/UserX/biz.asmx";
Service service = new Service();
Call call = (Call)service.createCall();
8848.com Web Service 说明文档
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new
QName("http://localhost/UserX/bizinfo","get_count"));
call.addParameter("ID", org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.addParameter("pwd",org.apache.axis.Constants.XSD_STRING,
ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://localhost/UserX/bizinfo/get_count");
String day = (String)call.invoke(new Object[] {"111", "s111"});
System.out.println(day);
} catch (Exception e) {
System.err.println(e.toString());
}
System.out.println("Total time is: "+(System.currentTimeMillis()-time));
}
}
posted on 2005-04-25 12:35 小鱼儿 阅读(3535) 评论(2)  编辑  收藏 所属分类: Web Service

Feedback

# re: 以java 为客户端 访问 Web Service。以下演示在J2SE 1.4.2 版本下访问Web[未登录] 2007-03-15 16:08 dd
fffffffffffffffffffffffffffffffffffff  回复  更多评论
  

# re: 以java 为客户端 访问 Web Service。以下演示在J2SE 1.4.2 版本下访问Web 2010-12-10 15:58 clucene
我测试通过,谢谢  回复  更多评论
  


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


网站导航: