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 小魚兒 閱讀(3549) 評論(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
          我測試通過,謝謝  回復  更多評論
            


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 新蔡县| 高唐县| 扎兰屯市| 宜兴市| 塔城市| 石林| 曲阳县| 射阳县| 韶关市| 古田县| 许昌县| 中江县| 如皋市| 桦南县| 衡东县| 青州市| 东兰县| 岐山县| 荣昌县| 延川县| 石泉县| 海丰县| 天全县| 永昌县| 互助| 高要市| 册亨县| 肇源县| 中阳县| 苍梧县| 吕梁市| 十堰市| 安丘市| 游戏| 万盛区| 阜康市| 班玛县| 睢宁县| 綦江县| 渝北区| 明星|