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


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


          網站導航:
           
          主站蜘蛛池模板: 临澧县| 凤翔县| 宁明县| 施甸县| 扎兰屯市| 明光市| 辽中县| 海阳市| 广宁县| 宕昌县| 宣汉县| 得荣县| 哈巴河县| 鸡东县| 克山县| 松溪县| 乌拉特前旗| 内江市| 兴义市| 新丰县| 诏安县| 女性| 云南省| 旌德县| 剑川县| 义乌市| 海淀区| 宾川县| 东乌珠穆沁旗| 开鲁县| 仁怀市| 永顺县| 都兰县| 阜阳市| 信阳市| 道孚县| 楚雄市| 丹寨县| 水城县| 宜君县| 紫金县|