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

时间:2019-02-25 12:40:02

标签: apache-camel apache-servicemix

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

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}]

有关如何执行此操作的任何提示?

1 个答案:

答案 0 :(得分: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>
相关问题