﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-happyfish-随笔分类-Web Service</title><link>http://www.blogjava.net/happyfish/category/1147.html</link><description /><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 12:25:03 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 12:25:03 GMT</pubDate><ttl>60</ttl><item><title>以java 为客户端 访问 Web Service。以下演示在J2SE 1.4.2 版本下访问Web</title><link>http://www.blogjava.net/happyfish/archive/2005/04/25/3699.html</link><dc:creator>小鱼儿</dc:creator><author>小鱼儿</author><pubDate>Mon, 25 Apr 2005 04:35:00 GMT</pubDate><guid>http://www.blogjava.net/happyfish/archive/2005/04/25/3699.html</guid><wfw:comment>http://www.blogjava.net/happyfish/comments/3699.html</wfw:comment><comments>http://www.blogjava.net/happyfish/archive/2005/04/25/3699.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/happyfish/comments/commentRss/3699.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/happyfish/services/trackbacks/3699.html</trackback:ping><description><![CDATA[以下演示在J2SE 1.4.2 版本下访问Web<BR>Service 的2 种方式。<BR>Axis<BR>需要下载axis, 地址为：<A href="http://apache.linuxforum.net/dist/ws/axis/1_1/axis-1_1-src.zip">http://apache.linuxforum.net/dist/ws/axis/1_1/axis-1_1-src.zip</A><BR>代码如下：<BR>import org.apache.axis.client.Service;<BR>import org.apache.axis.client.Call;<BR>import javax.xml.namespace.QName;<BR>import javax.xml.rpc.ParameterMode;<BR>public class t2 {<BR>public static void main(String[] args) {<BR>long time=System.currentTimeMillis();<BR>try {<BR>String endpoint="<A href="http://localhost/UserX/biz.asmx">http://localhost/UserX/biz.asmx</A>";<BR>Service service = new Service();<BR>Call call = (Call)service.createCall();<BR>8848.com Web Service 说明文档<BR>call.setTargetEndpointAddress(new java.net.URL(endpoint));<BR>call.setOperationName(new<BR>QName("<A href='http://localhost/UserX/bizinfo","get_count'>http://localhost/UserX/bizinfo","get_count</A>"));<BR>call.addParameter("ID", org.apache.axis.Constants.XSD_STRING,<BR>ParameterMode.IN);<BR>call.addParameter("pwd",org.apache.axis.Constants.XSD_STRING,<BR>ParameterMode.IN);<BR>call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);<BR>call.setUseSOAPAction(true);<BR>call.setSOAPActionURI("<A href="http://localhost/UserX/bizinfo/get_count">http://localhost/UserX/bizinfo/get_count</A>");<BR>String day = (String)call.invoke(new Object[] {"111", "s111"});<BR>System.out.println(day);<BR>} catch (Exception e) {<BR>System.err.println(e.toString());<BR>}<BR>System.out.println("Total time is: "+(System.currentTimeMillis()-time));<BR>}<BR>}<BR><img src ="http://www.blogjava.net/happyfish/aggbug/3699.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/happyfish/" target="_blank">小鱼儿</a> 2005-04-25 12:35 <a href="http://www.blogjava.net/happyfish/archive/2005/04/25/3699.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>