
2012年8月21日
1.logger.info(LogUtils.getLogFmt("ResponseXML", "ResultCode",
"ErrorDesc", "ServiceType", "Version"), new Object[] {
rs.getResponseXML(), rs.getResultCode(), rs.getErrorDesc(),
rs.getServiceType(), rs.getVersion() });
2.logger.error("error when call webservice: " + serviceType, e);
3.logger.info(LogUtils.getLogFmt("RequestXML"), requestXML);
posted @
2012-09-04 18:44 小熊寶貝的每一天 閱讀(185) |
評論 (0) |
編輯 收藏
ID屬性的聲明必須被置于最后<xs:attribute name="orderid" type="xs:string" use="required"/>
ComplexContent的用法:
<?xml version="1.0" encoding="UTF-8"?>
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
posted @
2012-08-21 17:23 小熊寶貝的每一天 閱讀(182) |
評論 (0) |
編輯 收藏
1.
準確說是一種Java XML數據綁定技術。
http://www.iteye.com/topic/582459:
<bind-xml name="borndate" node="attribute"/> ,name規定了這個值在xml中的顯示名,而node規定了該值的xml存儲方式,這里是用attribute形式進行存儲,即寫到了結點的屬性里。
2.Castor介紹----比較詳細易懂的BLOG:
http://www.open-open.com/lib/view/open1326514404093.htmlmapping.xml配置如下:
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd"> |
04 | < class name = "com.hoo.entity.Account" auto-complete = "true" > |
05 | < map-to xml = "Account" /> |
07 | < field name = "id" type = "integer" > |
08 | < bind-xml name = "id" node = "attribute" /> |
11 | < field name = "name" type = "string" > |
12 | < bind-xml name = "name" node = "element" /> |
15 | < field name = "email" type = "string" > |
16 | < bind-xml name = "email" node = "element" /> |
19 | < field name = "address" type = "string" > |
20 | < bind-xml name = "address" node = "element" /> |
23 | < field name = "birthday" type = "com.hoo.entity.Birthday" > |
24 | < bind-xml name = "生日" node = "element" /> |
28 | < class name = "com.hoo.entity.Birthday" > |
29 | < map-to xml = "birthday" /> |
31 | < field name = "birthday" type = "string" > |
32 | < bind-xml name = "birthday" node = "attribute" /> |
首先,看看這個xml文檔的根元素是mapping,在mapping中可以配置class。也就是我們要轉換的JavaObject的配置描述了。
class元素的name屬性就是配置的JavaObject的classpath路徑了。
關于class元素的auto-complate屬性,如果這個屬性的值為ture。那么編組后的xml,castor會自動給沒有在mapping配置文件進行配置的屬性自動編組(轉換)到xml中。如果為false,那么在mapping配置文件中出現的屬性將在編組后不現在在編組后的xml中。
map-to就是當前class編組后的xml文檔的節點元素名稱。
field就是描述JavaObject中的屬性,name是Java對象的屬性名稱,type是類型。關于配置的type類型也有規定,你可以參考:http://www.castor.org/xml-mapping.html的field配置講解。
而field還有其他的屬性配置,如get-method應該是getter方法、set-method應該是setter的方法、has-mehtod 應該是hashCode方法,有時候我們不一定要提高getter、setter方法,我們需要用自己的方法名稱來代替setter、getter。如果當前field配置的是集合類型,那么你需要給field元素配置collection屬性。
bind-xml就是綁定(編組)成xml后的xml內容的描述,name就是編組后xml的節點元素名稱,node有2個值,分別是 attribute、element。attribute是屬性,它會在節點元素的屬性中顯示,例如:<account id=”2”></account>
而element則是單獨的一個元素,例如:<account><id>2</id></account>
就這個樣子的。
mapping.xml還可以有其他標簽,如:
<include href="other_mapping_file.xml"/>
導入外部xml文件,可以分多個配置。
posted @
2012-08-21 16:01 小熊寶貝的每一天 閱讀(310) |
評論 (0) |
編輯 收藏