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("此處填寫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,研究之路 閱讀(382) 評論(0)  編輯  收藏 所屬分類: programming

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


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 彰化市| 宝鸡市| 婺源县| 南川市| 内江市| 和平区| 富平县| 门头沟区| 黔西县| 富裕县| 雅江县| 修武县| 萨嘎县| 金昌市| 股票| 高陵县| 阿克陶县| 长治县| 沂南县| 吕梁市| 石柱| 沙湾县| 普兰县| 罗田县| 铜陵市| 福鼎市| 农安县| 鞍山市| 正定县| 青州市| 嫩江县| 兰坪| 新昌县| 尚志市| 花垣县| 屏东市| 大安市| 虎林市| 潜山县| 松潘县| 健康|