posts - 15,comments - 29,trackbacks - 0
          Axis框架來自 Apache 開放源代碼組織,它是基于JAVA語言的最新的 SOAP 規范(SOAP 1.2)和 SOAP with Attachments 規范(來自 Apache Group )的開放源代碼實現。下面是它的核心引擎的體系結構圖:



          下面以 http://www.webxml.com.cn/webservices/DomesticAirline.asmx?Wsdl  航班查詢服務為例來分析開發客戶端的步驟。
          1.首先從http://ws.apache.org/axis/index.html上下載axis的程序包。

          2.運行cmd,進入下載包解壓后的目錄,運行   Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java -p client  http://www.webxml.com.cn/webservices/DomesticAirline.asmx?Wsdl  
          (其中-p是生成代碼的包名,根據需要設置)
           然后把生成的代碼拷貝到項目里面。

          3.拷貝axis里面的包到工程里面。

          4.客戶端代碼。

          public List<TicketInfo> getDomesticAirlinesTime(String startCity, String lastCity, String theDate) throws RemoteException, ServiceException {
                  DomesticAirline service 
          = new DomesticAirlineLocator();
                  GetDomesticAirlinesTimeResponseGetDomesticAirlinesTimeResult airlines;

                  airlines 
          = service.getDomesticAirlineSoap12().getDomesticAirlinesTime(startCity, lastCity,theDate, null);
              
                  MessageElement[] FOCElement 
          = airlines.get_any();
                  List FOCElementHead 
          = FOCElement[0].getChildren();//消息頭,DataSet對象    
                  List FOCElementBody = FOCElement[1].getChildren();//消息體信息,DataSet對象  

                  String nn 
          = FOCElementBody.get(0).toString();//消息體的字符串形式     
                  
                  

                  SAXReader reader 
          = new SAXReader();
                  Document document 
          = null;

                  
          try {
                      document 
          = document = DocumentHelper.parseText(nn);
                  }
           catch (Exception e) {
                      
          // TODO Auto-generated catch block
                      System.out.println(e.toString());
                  }

                  
                  
                  Element root 
          = (Element)document.getRootElement(); // 得到根元素    

                  List
          <TicketInfo> ticketInfoList = new ArrayList<TicketInfo>();
                  
          for (Object e : root.elements())
                  
          {
                      TicketInfo ticketInfo 
          = new TicketInfo();
                      Element element 
          = (Element) e;
                      ticketInfo.setAirlineCompany(element.elementText(
          "Company"));
                      ticketInfo.setFlightNumber(element.elementText(
          "AirlineCode"));
                      ticketInfo.setStartAirport(element.elementText(
          "StartDrome"));
                      ticketInfo.setEndAirport(element.elementText(
          "ArriveDrome"));
                      ticketInfo.setAirCraftType(element.elementText(
          "Mode"));
                      SimpleDateFormat  myFmt
          =new   SimpleDateFormat("HH:mm");     
                      
          try {
                          ticketInfo.setStartTime(myFmt.parse(element.elementText(
          "StartTime")));
                          ticketInfo.setEndTime(myFmt.parse(element.elementText(
          "ArriveTime")));
                      }
           catch (ParseException e1) {
                          
          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      }

                      
                      ticketInfoList.add(ticketInfo);
                  }

                  
                  
          return ticketInfoList;
              }

              
          }

          本來客戶端代碼應該是比較簡單的,但是這個例子的webservice服務端是用.net寫的,查詢后返回DataSet類型,java沒有對應的類型,所以只能把返回后的結果用xml來解析,然后在放入java的數據對象里面。
          posted @ 2008-12-04 10:04 流腥魚 閱讀(2871) | 評論 (0)編輯 收藏
          導出導入之前的準備 

           

          1.連接數據庫 conn system/password@//192.168.1.100:1521/dbcms

           

          2.創建用戶 create user newuser identified by password;


          3.授權 GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,DBA,CONNECT,RESOURCE,CREATE SESSION to newuser  


          導出命令,任選其一:
           

           1 將數據庫TEST完全導出,用戶名system 密碼manager 導出到D:\daochu.dmp中

             exp system/manager@TEST file=d:\daochu.dmp full=y

           2 將數據庫中system用戶與sys用戶的表導出

             exp system/manager@TEST file=d:\daochu.dmp owner=(system,sys)

           3 將數據庫中的表inner_notify、notify_staff_relat導出

              exp aichannel/aichannel@TESTDB2 file= d:\data\newsmgnt.dmp tables=(inner_notify,notify_staff_relat) 

           4 將數據庫中的表table1中的字段filed1以"00"打頭的數據導出

             exp system/manager@TEST file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"



          導入命令,任選其一:
           

          1 將D:\daochu.dmp 中的數據導入 TEST數據庫中。

             imp system/manager@TEST  file=d:\daochu.dmp

             imp aichannel/aichannel@HUST full=y  file=file= d:\data\newsmgnt.dmp ignore=y

             上面可能有點問題,因為有的表已經存在,然后它就報錯,對該表就不進行導入。

             在后面加上 ignore=y 就可以了。

           2 將d:\daochu.dmp中的表table1 導入

           imp system/manager@TEST  file=d:\daochu.dmp  tables=(table1)


           

          posted @ 2008-11-18 14:30 流腥魚 閱讀(275) | 評論 (0)編輯 收藏
               摘要:   l         FreeMarker是一個模板引擎,一個基于模板生成文本輸出的通用工具,使用純Java編寫 l         FreeMarker被設計用來生成HTML Web頁面,特別是基于MVC模式的應用程序 ...  閱讀全文
          posted @ 2008-09-24 15:17 流腥魚 閱讀(645) | 評論 (0)編輯 收藏

          在Firefox2中某些情況下輸入框雖然可以輸入,但在獲取焦點時沒有文本輸入光標的顯示,這個是非常惡心的bug,非常容易讓表單使用者有一種不能輸入的錯覺,即使后來嘗試知道可以輸入,但也無法判斷光標定位在哪兒。雖然慶幸的是Firefox3中解決了這個bug,但Firefox3還在beta階段,取代Firefox2還是需要一些時間的,下面就來仔細說一下這個問題:

          一、樣式為{position:absolute;}的容器中的表單輸入框在樣式為類似{overflow:auto;}的容器區域中失去光標

          可以通過 例一到例六 來了解最常見的情況。

          如果想整個body都出現失去光標,可以設置html和body兩個容器,請看 示例 。包括舉例的overflow:auto在內能引起該Bug的overflow屬性共有:

          overflow:auto
          overflow-x:auto;
          overflow-y:auto;
          overflow:scroll;
          overflow-x:scroll;
          overflow-y:scroll;
          overflow-x:hidden;
          overflow-y:hidden;

          除了避免使用overflow屬性的其他解決方案:

          1. 利用overflow:hidden代替產生bug的oveflow屬性
          2. 在具有上述overflow屬性的容器中加入position:relative,請看 實例 。
          3. 在positon:absolute的容器上加入同樣的oveflow屬性,同時注意在頁面出現的順序,見 例四
          4. 為使用能產生bug的oveflow屬性的容器選擇合適的標簽,比如fieldset,見 例六。

          二、樣式為{position:absolute;}的容器中的表單輸入框在iframe容器區域中失去光標

          可以通過 例七 來了解這個情況。IE6中為了解決下拉列表級別過高問題,往往需要用iframe來遮蓋它,偶爾疏忽忘記做瀏覽器限定就有可能導致上面的問題。

          現在看來Firefox2對iframe的處理bug還真不少,比如以前就發現了Firefox返回時Iframe的顯示Bug。

          posted @ 2008-06-25 16:34 流腥魚 閱讀(310) | 評論 (1)編輯 收藏

           JS 對象介紹 1.document.formName.item("itemName") 問題
          說明:IE下,可以使用document.formName.item("itemName")或document.formName.elements["elementName"];Firefox下,只能使用document.formName.elements["elementName"].
          解決方法:統一使用document.formName.elements["elementName"].

          2.集合類對象問題
          說明:IE下,可以使用()或[]獲取集合類對象;Firefox下,只能使用[]獲取集合類對象.
          解決方法:統一使用[]獲取集合類對象.

          3.自定義屬性問題
          說明:IE下,可以使用獲取常規屬性的方法來獲取自定義屬性,也可以使用getAttribute()獲取自定義屬性;Firefox下,只能使用getAttribute()獲取自定義屬性.
          解決方法:統一通過getAttribute()獲取自定義屬性.

          4.eval("idName")問題
          說明:IE下,,可以使用eval("idName")或getElementById("idName")來取得id為idName的HTML對象;Firefox下只能使用getElementById("idName")來取得id為idName的HTML對象.
          解決方法:統一用getElementById("idName")來取得id為idName的HTML對象.

          5.變量名與某HTML對象ID相同的問題
          說明:IE下,HTML對象的ID可以作為document的下屬對象變量名直接使用;Firefox下則不能.Firefox下,可以使用與HTML對象ID相同的變量名;IE下則不能。
          解決方法:使用document.getElementById("idName")代替document.idName.最好不要取HTML對象ID相同的變量名,以減少錯誤;在聲明變量時,一律加上var,以避免歧義.

          7.input.type屬性問題
          說明:IE下input.type屬性為只讀;但是Firefox下input.type屬性為讀寫.

          9.event.x與event.y問題
          說明:IE下,even對象有x,y屬性,但是沒有pageX,pageY屬性;Firefox下,even對象有pageX,pageY屬性,但是沒有x,y屬性.
          解決方法:使用mX(mX = event.x ? event.x : event.pageX;)來代替IE下的event.x或者Firefox下的event.pageX.

          10.event.srcElement問題
          說明:IE下,event對象有srcElement屬性,但是沒有target屬性;Firefox下,event對象有target屬性,但是沒有srcElement屬性.
          解決方法:使用obj(obj = event.srcElement ? event.srcElement : event.target;)來代替IE下的event.srcElement或者Firefox下的event.target.

          13.frame問題
          以下面的frame為例:
          <frame src="xxx.html" id="frameId" name="frameName" />

          (1)訪問frame對象:
          IE:使用window.frameId或者window.frameName來訪問這個frame對象.
          Firefox:只能使用window.frameName來訪問這個frame對象.
          另外,在IE和Firefox中都可以使用window.document.getElementById("frameId")來訪問這個frame對象.

          (2)切換frame內容:
          在IE和Firefox中都可以使用window.document.getElementById("testFrame").src = "xxx.html"或window.frameName.location = "xxx.html"來切換frame的內容.

          如果需要將frame中的參數傳回父窗口,可以在frme中使用parent來訪問父窗口。例如:parent.document.form1.filename.value="Aqing";

          14.body問題
          Firefox的body在body標簽沒有被瀏覽器完全讀入之前就存在;而IE的body則必須在body標簽被瀏覽器完全讀入之后才存在.

          例如:
          Firefox:
          <body>
          <script type="text/javascript">
          document.body.onclick = function(evt){
          evt = evt || window.event;
          alert(evt);
          }
          </script>
          </body>
          IE&Firefox:
          <body>
          </body>
          <script type="text/javascript">
          document.body.onclick = function(evt){
          evt = evt || window.event;
          alert(evt);
          } </script>

          15. 事件委托方法
          IE:document.body.onload = inject; //Function inject()在這之前已被實現

          Firefox:document.body.onload = inject();

          有人說標準是:
          document.body.onload=new Function('inject()');

          16. firefox與IE(parentElement)的父元素的區別
          IE:obj.parentElement
          firefox:obj.parentNode

          解決方法: 因為firefox與IE都支持DOM,因此使用obj.parentNode是不錯選擇.

          17.innerText在IE中能正常工作,但是innerText在FireFox中卻不行.
          解決方法:
          if(navigator.appName.indexOf("Explorer") > -1){

              document.getElementById('element').innerText = "my text";

          } else{

              document.getElementById('element').textContent = "my text";

          }

          18. FireFox中類似 obj.style.height = imgObj.height 的語句無效
          解決方法:
          obj.style.height = imgObj.height + 'px';

          19. ie,firefox以及其它瀏覽器對于 table 標簽的操作都各不相同,在ie中不允許對table和tr的innerHTML賦值,使用js增加一個tr時,使用appendChile方法也不管用。
          解決方法:
          //向table追加一個空行:
          var row = otable.insertRow(-1);
          var cell = document.createElement("td");
          cell.innerHTML = " ";
          cell.className = "XXXX";
          row.appendChild(cell);

          20. padding 問題
          padding 5px 4px 3px 1px FireFox無法解釋簡寫,

          必須改成 padding-top:5px; padding-right:4px; padding-bottom:3px; padding-left:1px;

          21. 消除ul、ol等列表的縮進時
          樣式應寫成:list-style:none;margin:0px;padding:0px;

          其中margin屬性對IE有效,padding屬性對FireFox有效

          22. CSS透明
          IE:filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=60)。

          FF:opacity:0.6。

          23. CSS圓角
          IE:不支持圓角。

          FF: -moz-border-radius:4px,或者-moz-border-radius-topleft:4px;-moz-border- radius-topright:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius- bottomright:4px;。

          24. CSS雙線凹凸邊框
          IE:border:2px outset;。

          FF: -moz-border-top-colors: #d4d0c8 white;-moz-border-left-colors: #d4d0c8 white;-moz-border-right-colors:#404040 #808080;-moz-border-bottom-colors:#404040 #808080;

          25.ie支持document.all 而firefox 不支持
          改用下面三個tag的其中一個來代替document.all
          getElementsByTagName("tagName") 可以得到得到所有標簽元素的集合
          getElementById("idName")          可以按id得到某一元素
          getElementsByName("Name")            可以得到按name屬性得到某一元素

          26、firefox 中使用innerHTML 的方法
          <div id="online"></div>
          document.all.online.innerHTML; //這種方法在IE中可以使用,但不是標準方法
          document.getElementById("online").innerHTML; //這樣firefox就能使用innerHTML了

          27、eval()與window.execScript()執行腳本
          IE、firerox均支持eval(),firefox不支持window.execScript()

          解決:統一使用eval()

          28、對事件處理函數的重寫
          解決:(例):如對document的onclick()重寫,統一使用document.onclick = function(){…}

           

          posted @ 2008-06-20 15:55 流腥魚 閱讀(670) | 評論 (0)編輯 收藏

                  現在的系統為了得到更好的用戶體驗,都加入了ajax的特效,只要用到了ajax的代碼,就會引來一大堆js代碼,這些代碼其實也挺占用帶寬的,為了使網頁加載得更快,決定在項目中才用網上流行的js壓縮器來壓縮代碼。壓縮后的代碼基本可以抽掉40%左右的脂肪。
           
                  找到幾個壓縮器,發現很多壓縮器壓縮后的js代碼都出現這樣或那樣的問題

          ESC 1.14   http://www.saltstorm.net/depo/esc/?pod=js   壓縮后有些中文會出現問號(我的js代碼是用utf-8格式)
          jsmin http://www.crockford.com/javascript/jsmin.html   壓縮后有些中文會出現問號
          dean edwards的packer http://dean.edwards.name/packer/ 壓縮后的js代碼會出現部分分號或大括號丟失,導致語法錯誤


          最后找到了yuicompressor-2.3.4 http://developer.yahoo.com/yui/compressor/ 感覺很好用,壓縮后無損代碼,而且連css也可以壓縮,壓縮的時候很多參數可以設置,可以制定js代碼的編碼格式等,java運行,本人寫了一個bat批處理遍歷制定文件夾里面的所有js和css文件進行壓縮。

          項目中用到網上流行的ext2 js庫,所以項目中有很多js代碼,于是寫的bat遍歷文件壓縮代碼

          (dir %1 /aa //s  | findstr //c:"js">tmp.txt
          for /%%i in (tmp.txt) do java -jar yuicompressor-2.3.4.jar --type js --charset utf-8 -%%i.tmp %%i  & copy %%i".tmp" %%& del %%i".tmp"


          (dir 
          %1 /aa //s  | findstr //c:"css">tmp.txt
          for /%%i in (tmp.txt) do java -jar yuicompressor-2.3.4.jar --type css --charset utf-8 -%%i.tmp %%i  & copy %%i".tmp" %%& del %%i".tmp"


          保存為  jscompressor.bat 運行的時候在輸入 jscompressor <path>  (<path>是我們指定的路徑) 就可以批量進行壓縮,壓縮后替換壓縮前的代碼。



          下面是一些參數的說明。

          ==============================================================================
          YUI Compressor
          ==============================================================================

          NAME

            YUI Compressor 
          - The Yahoo! JavaScript and CSS Compressor

          SYNOPSIS

            Usage: java 
          -jar yuicompressor-x.y.z.jar [options] [input file]

            Global Options
              
          -h, --help                Displays this information
              
          --type <js|css>           Specifies the type of the input file
              
          --charset <charset>       Read the input file using <charset>
              
          --line-break <column>     Insert a line break after the specified column number
              
          -v, --verbose             Display informational messages and warnings
              
          -<file>                 Place the output into <file>. Defaults to stdout.

            JavaScript Options
              
          --nomunge                 Minify only, do not obfuscate
              
          --preserve-semi           Preserve all semicolons
              
          --disable-optimizations   Disable all micro optimizations

          DESCRIPTION

            The YUI Compressor is a JavaScript compressor which, in addition to removing
            comments and white
          -spaces, obfuscates local variables using the smallest
            possible variable name. This obfuscation is safe, even when using constructs
            such as 
          'eval' or 'with' (although the compression is not optimal is those
            cases) Compared to jsmin, the average savings is around 
          20%.

            The YUI Compressor is also able to safely compress CSS files. The decision
            on which compressor is being used is made on the file extension (js or css)

          GLOBAL OPTIONS

            
          -h, --help
                Prints help on how to use the YUI Compressor

            
          --line-break
                Some source control tools don
          't like files containing lines longer than,
                say 8000 characters. The linebreak option is used in that case to split
                
          long lines after a specific column. It can also be used to make the code
                more readable, easier to debug (especially with the MS Script Debugger)
                Specify 
          0 to get a line break after each semi-colon in JavaScript, and
                after each rule in CSS.

            
          --type js|css
                The type of compressor (JavaScript or CSS) is chosen based on the
                extension of the input file name (.js or .css) This option is required
                
          if no input file has been specified. Otherwise, this option is only
                required 
          if the input file extension is neither 'js' nor 'css'.

            
          --charset character-set
                If a supported character set is specified, the YUI Compressor will use it
                to read the input file. Otherwise, it will assume that the platform
          's
                default character set is being used. The output file is encoded using
                the same character set.

            
          -o outfile
                Place output in file outfile. If not specified, the YUI Compressor will
                
          default to the standard output, which you can redirect to a file.

            
          -v, --verbose
                Display informational messages and warnings.

          JAVASCRIPT ONLY OPTIONS

            
          --nomunge
                Minify only. Do not obfuscate local symbols.

            
          --preserve-semi
                Preserve unnecessary semicolons (such as right before a 
          '}') This option
                is useful when compressed code has to be run through JSLint (which is the
                
          case of YUI for example)

            
          --disable-optimizations
                Disable all the built
          -in micro optimizations.





           

          posted @ 2008-06-19 00:45 流腥魚 閱讀(1994) | 評論 (4)編輯 收藏
          僅列出標題
          共2頁: 上一頁 1 2 
          主站蜘蛛池模板: 博白县| 山阳县| 化隆| 南部县| 和静县| 城口县| 颍上县| 桂林市| 大方县| 龙海市| 扶风县| 长子县| 宿迁市| 荆门市| 恩施市| 微山县| 周宁县| 木兰县| 内丘县| 定边县| 马龙县| 凌云县| 张家港市| 彰化市| 瑞金市| 福海县| 宜州市| 唐海县| 揭东县| 留坝县| 垦利县| 高雄县| 界首市| 张家界市| 沙田区| 阿拉善盟| 余姚市| 姚安县| 扶绥县| 嘉禾县| 信阳市|