2014-10-08 42 views
1

我使用wso2esb 4.7.0和wso2dss 3.1.0.i要選擇從table.For一些列,我在DSS使用下面的查詢:Wso2esb:錯誤而在開關辦案空值

select roleid,rolename,rolecode from mrole where clientid = ? and ModifiedOn = ? 

它的工作在DSS罰款以及ESB also.Output是這樣的:

{"roleid":"1077282521908571","rolename":"adminrole","rolecode":"adminrole"},{"roleid":"1077282521908571","rolename":"adminrole","rolecode":"adminrole"},{"roleid":"1077278842127704","rolename":"everyonerole","rolecode":"everyonerole"},{"roleid":"1077282521908571","rolename":"adminrole","rolecode":"adminrole"} 

這是在第二種情況下一個case.Now,如果我沒有得到modifiedon那麼明顯它顯示了在像DSS錯誤:

Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processNormalQuery' 
DS Code: DATABASE_ERROR 
Source Data Service:- 
Name: muser_DataService2.0 
Location: /muser_DataService2.0.dbs 
Description: N/A 
Default Namespace: http://ws.wso2.org/dataservice 
Current Request Name: Select_Role_Details_Op 
Current Params: {clientid=214057357158656, modifiedon=} 
Nested Exception:- 
java.lang.NumberFormatException: For input string: "" 

爲了解決這個我使用開關殼體在像ESB:

<switch source="get-property('ModifiedOn')"> 
      <case regex="''"> 
       <property name="ModifiedOn" value="0" scope="default" type="STRING"/> 
       <log level="custom"> 
        <property name="ModifiedOn in case of null: " 
          expression="get-property('ModifiedOn')"/> 
       </log> 
      </case>   
</switch> 

它示出了在ESB警告消息,如:

[2014-10-08 11:43:54,100] WARN - SwitchCase Provided character sequence for switch case condition is 'null'. Switch case will not be executed. 

和不執行開關情況下,它直接地向前移動,併產生故障以及dss顯示錯誤,如何在switch case中給出null條件?

回答

3

使用布爾 XPath函數來驗證你的財產有:

<filter xpath="boolean(get-property('ModifiedOn'))"> 
    <then> 
     ... 
    </then> 
    <else> 
     ... 
    </else> 
</filter>