<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Vikings

    2008年8月7日 #

    Dom4j的CDATA問題與UTF-8字符集

     

    本文轉(zhuǎn)自:http://www.b9527.net/?q=node/1124
     
    原文如下:
     

    1. 寫入文件的格式

    寫入 Xml 文件的時(shí)候默認(rèn)是全部?jī)?nèi)容寫為一行,這個(gè)可以通過加入 Format 來解決:

    OutputFormat format = OutputFormat.createPrettyPrint();

    2. Xml 中文問題

    2.1 Xml 最好設(shè)為 UTF-8 格式,

    format.setEncoding("utf-8");

    2.2 不要用 FileWriter 輸出雙字節(jié),改為 FileOutputStream 輸出單字節(jié):

    XMLWriter output = new XMLWriter(new FileOutputStream(configFile), format);

    3. CDATA類型文本輸入

    Element conTblOpr = rowElement.addElement(XmlDBConstants.CON_TBL_OPR);// 加入節(jié)點(diǎn)

    DefaultCDATA conTblOprCdata = new DefaultCDATA(conTblOprField);// CDATA格式化

    conTblOpr.add(conTblOprCdata );// 加入CDATA文本

    Dom4j 里面已經(jīng)內(nèi)置了對(duì) CDATA 類型文本的支持,不要硬編碼去在文本兩邊加<![CDATA[***]]>。

     

    posted @ 2011-07-05 00:12 Vikings 閱讀(2234) | 評(píng)論 (0)編輯 收藏

    實(shí)施WebService Security[WS-Security1.0]的Encrypt和Sign模式(XFire+WSS4J)

    轉(zhuǎn)自:
    http://www.tkk7.com/security/archive/2006/08/08/xfire_wss4j.html

    thanks for springside

    鑒于很多系統(tǒng)需要實(shí)施WS-Security的標(biāo)準(zhǔn),我們?cè)赟pringSide中提供了XFire+WSS4J的Demo,本文介紹SpringSide中Spring+XFire+WSS4J的基本配置

    [WebService Server端配置]
    第一,創(chuàng)建一個(gè)基本的BookService
    public interface BookService {
        
    /** *//**
         * 按書名模糊查詢圖書
         
    */

        List findBooksByName(String name);

        
    /** *//**
         * 查找目錄下的所有圖書
         *
         * 
    @param categoryId 如果category為null或“all”, 列出所有圖書。
         
    */

        List findBooksByCategory(String categoryId);

        
    /** *//**
         * 列出所有分類.
         *
         * 
    @return List<Category>,或是null。
         
    */

        List getAllCategorys();
    }
    第二,接口擴(kuò)展,即Extend基本的BookService,在XFire中,不同的WSS4J策略需要針對(duì)不同的ServiceClass,否則<inHandlers>里面的定義會(huì)Overlap。


       <!--BookService 基類-->
        
    <bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" abstract="true">
            
    <property name="serviceFactory" ref="xfire.serviceFactory"/>
            
    <property name="xfire" ref="xfire"/>
        
    </bean>

        
    <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            
    <property name="mappings">
                
    <value>
                    /BookService=bookService
                    /BookServiceWSS4J=bookServiceWSS4J
                    /BookServiceWSS4JEnc=bookServiceWSS4JEnc
                    /BookServiceWSS4JSign=bookServiceWSS4JSign
                
    </value>
            
    </property>
        
    </bean>

       
    <!--(1)BookWebService 不需要認(rèn)證-->
        
    <bean id="bookService" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceFactory" ref="xfire.serviceFactory"/>
            
    <property name="xfire" ref="xfire"/>
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookService"/>
        
    </bean>

        
    <!--  (3)BookWebService 使用 WSS4J驗(yàn)證-->
        
    <bean id="bookServiceWSS4J" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4J"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandler"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>

        
    <bean id="domInHandler" class="org.codehaus.xfire.util.dom.DOMInHandler"/>

        
    <bean id="wss4jInHandler" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
                
    <props>
                    
    <prop key="action">UsernameToken</prop>
                    
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
                
    </props>
            
    </property>
        
    </bean>

        
    <bean id="validateUserTokenHandler" class="org.springside.bookstore.plugins.xfire.wss4j.WSS4JTokenHandler"/>
        
        
    <!--  (4)BookWebService 使用 WSS4J驗(yàn)證 Encrypt模式-->
        
    <bean id="bookServiceWSS4JEnc" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4JEnc"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandlerEnc"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>
            
        
    <bean id="wss4jInHandlerEnc" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
              
    <props>
                
    <prop key="action">Encrypt</prop>
                
    <prop key="decryptionPropFile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_enc.properties</prop>
                
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
              
    </props>
            
    </property>
        
    </bean>
        
        
    <!--  (5)BookWebService 使用 WSS4J驗(yàn)證 Signature模式-->
        
    <bean id="bookServiceWSS4JSign" class="org.codehaus.xfire.spring.remoting.XFireExporter">
            
    <property name="serviceBean" ref="bookManager"/>
            
    <property name="serviceClass" value="org.springside.bookstore.plugins.xfire.service.BookServiceWSS4JSign"/>
            
    <property name="inHandlers">
                
    <list>
                    
    <ref bean="domInHandler"/>
                    
    <ref bean="wss4jInHandlerSign"/>
                    
    <ref bean="validateUserTokenHandler"/>
                
    </list>
            
    </property>
        
    </bean>
        
        
    <bean id="wss4jInHandlerSign" class="org.codehaus.xfire.security.wss4j.WSS4JInHandler">
            
    <property name="properties">
              
    <props>
                
    <prop key="action">Signature</prop>
                
    <prop key="signaturePropFile">org/springside/bookstore/plugins/xfire/wss4j/insecurity_sign.properties</prop>
                
    <prop key="passwordCallbackClass">org.springside.bookstore.plugins.xfire.wss4j.PasswordHandler</prop>
              
    </props>
            
    </property>
        
    </bean>
        
    </beans>

    posted @ 2008-10-29 01:55 Vikings 閱讀(389) | 評(píng)論 (0)編輯 收藏

    簡(jiǎn)化spring中的事務(wù)管理配置(ZT)

    <!-- Transactional proxy for the services -->  
        
    <bean id="baseTxProxy" lazy-init="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
            
    <property name="transactionManager"><ref bean="transactionManager"/></property>  
            
    <property name="transactionAttributes">  
                
    <props>  
                    
    <prop key="*">PROPAGATION_REQUIRED</prop>  
                
    </props>  
            
    </property>  
        
    </bean>  
      
        
    <bean id="itemService" parent="baseTxProxy">  
            
    <property name="target">  
                
    <bean class="ItemServiceImpl" autowire="byName"/>  
            
    </property>  
        
    </bean>  
    這樣的話baseTxProxy也可能被實(shí)例化。是不是加上abstract="true"屬性,把baseTxProxy只是當(dāng)作一個(gè)模板比較好?因?yàn)橹恍枰猧temservice這個(gè)bean。

    posted @ 2008-08-07 00:12 Vikings 閱讀(312) | 評(píng)論 (0)編輯 收藏

    主站蜘蛛池模板: 处破痛哭A√18成年片免费| 日韩精品亚洲专区在线观看| 亚洲日韩精品无码专区加勒比 | 9277手机在线视频观看免费| 亚洲伊人久久大香线蕉| 国产在线98福利播放视频免费| 中文字幕的电影免费网站| 亚洲精品电影天堂网| 国产午夜影视大全免费观看| 成人性生交大片免费看中文| 亚洲综合伊人制服丝袜美腿| 免费在线观看中文字幕| 99热在线免费观看| 黄色网址免费在线| 亚洲精品美女在线观看| 亚洲成a人片在线观看老师| 91av在线免费视频| 产传媒61国产免费| 亚洲中文无码mv| 亚洲国产二区三区久久| 国产精品高清全国免费观看| 久久99精品视免费看| 欧美日韩亚洲精品| 亚洲福利电影一区二区?| 亚洲人成网站观看在线播放| 精品国产sm捆绑最大网免费站| 一个人看的在线免费视频| 久久精品国产亚洲AV久| 亚洲另类激情综合偷自拍图| 午夜一级免费视频| 69视频免费在线观看| 久久免费视频一区| 国产亚洲美女精品久久久久| 亚洲天堂电影在线观看| 中文无码亚洲精品字幕| 亚洲AV色香蕉一区二区| 亚洲综合区小说区激情区| 日韩精品无码人妻免费视频 | 精品亚洲永久免费精品| 四虎1515hm免费国产| 性xxxx视频播放免费|