java如何在camel配置中定义公共路由体?
我在camel配置中有两个route
路线1
<route>
<from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Contents-type">
<constant>application/octet-stream</constant>
</setHeader>
<setHeader headerName="SOAPAction">
<constant>vc</constant>
</setHeader>
<setHeader headerName="Accept">
<constant>application/xml</constant>
</setHeader>
<to uri="bean:samlWsBean" />
<choice>
<when>
<simple>${in.header.isvalid} contains "true"</simple>
<to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
</when>
<otherwise>
<to uri="velocity:file:///path/samlerrorresponse.vm"/>
</otherwise>
</choice>
</route>
路线2
<route>
<from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<setHeader headerName="Contents-type">
<constant>application/octet-stream</constant>
</setHeader>
<setHeader headerName="SOAPAction">
<constant>vc</constant>
</setHeader>
<setHeader headerName="Accept">
<constant>application/xml</constant>
</setHeader>
<to uri="bean:samlWsBean" />
<choice>
<when>
<simple>${in.header.isvalid} contains "true"</simple>
<to uri="cxf:bean:backendService?dataFormat=PAYLOAD"/>
</when>
<otherwise>
<to uri="velocity:file:///path/samlerrorresponse.vm"/>
</otherwise>
</choice>
</route>
两条路线只有一条线路不同
你有这个吗
<from uri="cxf:bean:soapProxy1?dataFormat=PAYLOAD" />
另一个有这个
<from uri="cxf:bean:soapProxy2?dataFormat=PAYLOAD" />
所以我可以把公共体放在配置中的其他地方,并在两个路径中引用吗
# 1 楼答案
当没有人回复我的问题时,我又开始在网上搜索,我找到了这样的解决方案
然后你可以这样调用
有关更多帮助,请参见this和this,希望这将帮助其他人