我使用mule的应用程序非常简单。此应用程序应从通过http请求发送的值(人员名称)定义的数据库中检索一些值。 我这里使用的使用的示例:https://docs.mulesoft.com/mule-user-guide/v/3.6/database-connector-examples根据mule中http的属性获取数据库中的值
我的流程:
<http:listener-config name="HTTP_Listener_Configuration_DB2"
host="localhost" port="8092" doc:name="HTTP Listener Configuration" />
<flow name="database_connector_mysql2Flow">
<http:listener config-ref="HTTP_Listener_Configuration_DB2"
path="/*" doc:name="HTTP" />
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[select Id, name, lastname, Email, phone from employee where name=#[message.inboundProperties['name']];]]></db:parameterized-query>
</db:select>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
运行的应用程序后,我设置以下网址浏览器:
http://localhost:8092/?name=Karam
但是,所有我得到的是只有空括号[]
我怀疑这部分mySql查询不正确:
其中name =#[message.inboundProperties [ '名']]
任何帮助吗?
我使用另一个数据库。我有'卡拉姆' –
也recod名称另外,如果我使用以下查询:选择ID,姓名,姓氏,电子邮件,来自员工的电话,其中名称='卡拉姆';它工作没有问题。只有当我使用name =#[message.inboundProperties ['name']]; –
这就是它在答案中所说的......你在'http:// localhost:8092 /?name = Karam'中传递查询参数,并且在你正在使用'inboundProperties'的sql查询中不起作用...使用'#[message.inboundProperties.'http.query.params'.name]'而不是 –