在查询参数apache camel spring DSL之后添加选项

问题描述 投票:1回答:1

我正在尝试对以下网址进行获取请求:

http://hellostackexchange?mynameiskees.json

问题是我没有看到在将查询参数添加到uri后如何添加选项参数。我的尝试如下:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
   <route id="hello stackexchange">
       <from uri="timer://counting_camera?fixedRate=true&amp;period=1000" />
       <setHeader headerName="CamelHttpQuery">
       <simple>"mynameiskees.json"</simple>
        </setHeader>
       <to uri=http4://hellostackexchange/>
       <to uri = "direct:test"/>
   </route>

   <route id = "final">
    <from uri="direct:test?authUsername=kees&amp;authPassword=kees"/>
    <to uri="log:result"/>
  </route>
</camelContext>

这会导致错误:

There are 2 parameters that couldn't be set on the endpoint. Check the uri 
if the parameters are spelt correctly and that they are properties of the 
endpoint. Unknown parameters=[{authPassword=kees, authUsername=kees}]

关于如何做到这一点的任何提示?

apache-camel apache-servicemix
1个回答
0
投票

在@Namphibian的帮助下,我执行了以下操作,您只需将查询参数添加到标题中,并将选项添加到您的uri:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
   <route id="hello stackexchange">
       <from uri="timer://counting_camera?fixedRate=true&amp;period=1000" />
       <setHeader headerName="CamelHttpQuery">
           <simple>"mynameiskees.json"</simple>
       </setHeader>
       <to uri="http4://hellostackexchange?authUsername=kees&amp;authPassword=kees"/>
       <to uri = "log:result"/>
   </route>
</camelContext>
© www.soinside.com 2019 - 2024. All rights reserved.