2014-09-26 18 views
0
Sample.properties 
================= 
http.header.amisys.accept.value=arun/vnd.dsths.services-v1+xml 

1)Above XSL automatically loaded when my server starts. 
2)I have tried <int:enricher> element but it is not helped me. 

示例代碼:下面是我嘗試過的代碼位,可以有人建議我這個。如何使用彈簧積分元素將屬性值從屬性文件移動到有效載荷對象

<int:channel id="PQLegacySecurity-InputChannel" /> 
    <int:chain input-channel="PQLegacySecurity-InputChannel" > 
     <!-- Split the Search Request Params from Xml --> 
     <int-xml:xpath-splitter> 
     <int-xml:xpath-expression expression="//LegacySecurity" namespace map="xmlMessageNamespace" /> 
     </int-xml:xpath-splitter>   
     <int:enricher >    
      <int:payload name="testPayload" expression="${http.header.amisys.accept.value}"/>     
     </int:enricher>   
    </int:chain>   

Actual Payload Object:Below is the xml which does not contain testPayload property. 

    <?xml version="1.0" encoding="UTF-8"?><LegacySecurity> 
        <businessArea>%%%%%%</businessArea> 
        <LegacySystem>%%%%%</LegacySystem> 
        <LegacyUserID>%%%%%</LegacyUserID> 
        <LegacyPassword>%%%%%</LegacyPassword> 
        <OtherLogin/> 
        <OtherPassword/> 
        <AddSecurLogin/> 
        <AddSecurPassword/> 
        </LegacySecurity> 

預期負載對象:以下對象包含新的元素testPayload節點,我應該能夠添加

    <?xml version="1.0" encoding="UTF-8"?><LegacySecurity> 
        <businessArea>%%%%%%</businessArea> 
        <LegacySystem>%%%%%</LegacySystem> 
        <LegacyUserID>%%%%%</LegacyUserID> 
        <LegacyPassword>%%%%%</LegacyPassword> 
        <OtherLogin/> 
        <OtherPassword/> 
        **<testPayload>arun/vnd.dsths.services-v1+xml</testPayload>** 
        <AddSecurLogin/> 
        <AddSecurPassword/> 
        </LegacySecurity> 

回答

1

您可以使用XSLT轉換它。類似於下面的內容,儘管你需要從spring文檔中找出正確使用變壓器的方法。

通知您可以通過傳遞參數給XSLT

<int-xml:xslt-transformer result-transformer="toDocumentTransformer" result-type="StringResult" xsl-resource="/xslt/addTestPayload.xslt"> 
    <int-xml:xslt-param name="testPayload" value="${http.header.amisys.accept.value}"/> 
</int-xml:xslt-transformer> 

在XSLT文件,用這個來拿起參數:

<xsl:param name="testPayload" /> 

如果你有其他的變化,你需要做給消息你可以使用相同的xslt。

+0

\t \t \t Hari 2014-09-28 13:13:36

+0

我已經在上面嘗試過了,由於:org.springframework.beans.factory.NoSuchBeanDefinitionException:沒有名爲'resultToString'的bean被定義爲 – Hari 2014-09-28 13:14:23

+0

我試圖通過移除result-transformer =「resultToString」來嘗試另一個,但它給出錯誤,如編譯器警告: 第6行:非法屬性'價值'。,你能幫我解決這個問題 – Hari 2014-09-28 13:26:23

相關問題