1. install the following software
          jre 1.5 or 1.6,  tomcat 5525, eclipse, axis2

          and in eclipse preferences set tomcat to web server, set jre env and set axis2's runtime

          2. create a java project and add axis2 runtime library to its build library

          test ws client sample code:

          public class TestSms
          {
          private static EndpointReference targetEPR = new EndpointReference(
             "http://cdl:8080/axis2/services/Version");

           public static OMElement getGetLeftElement(){
                     OMFactory fac=OMAbstractFactory.getOMFactory();
                     OMNamespace omNs=fac.createOMNamespace("此處填寫(xiě)WS的命名空間","hw");
                     OMElement method=fac.createOMElement("WS 方法名",omNs);
                     OMElement value = fac.createOMElement("參數(shù)一", omNs);
                     value.addChild(fac.createOMText(value, "值一"));
                     method.addChild(value);
                    
                     value = fac.createOMElement("參數(shù)二", omNs);
                     value.addChild(fac.createOMText(value, "值2"));
                     method.addChild(value);
                    
                   
                     return method;
              }
                
                 public static void main(String[] args){
                        try{
                               Options options=new Options();
                               options.setTo(targetEPR);
                               options.setAction("命名空間/WS 方法名");
                               ServiceClient sender=new ServiceClient();
                               sender.setOptions(options);
                               OMElement sayHello=TestSms.getGetLeftElement();
                               //WSDLConstants.
                              
                               OMElement result=sender.sendReceive(sayHello);
                              
                               OMElement elem = result.getFirstElement();
                               System.out.println(elem.getText());
                               //System.out.println(result);
                        }
                        catch(Exception axisFault){
                               axisFault.printStackTrace();
                        }
                 }

          }



          ref: http://zhangjunhd.blog.51cto.com/113473/23690
          posted on 2007-10-25 20:58 Java,研究之路 閱讀(378) 評(píng)論(0)  編輯  收藏 所屬分類: programming

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 武汉市| 湖州市| 闸北区| 礼泉县| 灵丘县| 泗阳县| 黔东| 康定县| 营口市| 牟定县| 隆化县| 商南县| 安图县| 荃湾区| 东辽县| 阳信县| 清远市| 焉耆| 临桂县| 拉萨市| 特克斯县| 云南省| 兴仁县| 梁平县| 内丘县| 锡林浩特市| 安乡县| 浙江省| 建湖县| 伊通| 临桂县| 南京市| 剑河县| 巴林左旗| 教育| 珠海市| 布尔津县| 丰县| 光泽县| 崇左市| 新津县|