我想编写一个mule应用程序,它将读取未处理记录的数据库,将它们以JSON有效负载格式包装起来,然后打开REST web服务。 我能够从数据库中读取记录并能够以JSON格式转换数据库记录。但是,每当我运行该应用程序我得到以下异常Mule - java.lang.String不能转换为java.util.Map
java.lang.ClassCastException:java.lang.String中不能转换为java.util.Map
这里是我的Mule配置XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="my_database_name" doc:name="MySQL Configuration"/>
<http:request-config name="HTTP_Request_Configuration" protocol="HTTPS" host="example.net" port="8000" basePath="API" doc:name="HTTP Request Configuration"/>
<flow name="cwg_clientFlow">
<poll doc:name="Poll">
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT * FROM cwg_ws_data WHERE SyncFlag = 0]]></db:parameterized-query>
</db:select>
</poll>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<json:object-to-json-transformer doc:name="Object to JSON" />
<logger message="JSON Payload is #[payload]" level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Configuration" path="/cwg" method="POST" doc:name="HTTP">
<http:request-builder>
<http:query-params expression="#[payload]"/>
<http:header headerName="access_token" value="MQTgpMUmyQLt134maB6vPp6oWFgMtGsqzIlpCN74"/>
</http:request-builder>
</http:request>
<logger message="webservice response #[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
我无法理解它出错的地方
请帮助我,我正在尝试此过去两天。
预先感谢
-Paresh([email protected])
好像你正在使用的有效载荷作为HTTP请求的查询参数,但为了将它们设置为他们需要的是一个Map的表达式(查询键/查询值) 。这是铸造错误的关键。你实际需要什么作为查询参数? – afelisatti
由于我以JSON格式转换数据库行并尝试将此JSON传递给webservice,因此webservice期望JSON格式的有效内容。 –
然后你不需要查询参数。 – afelisatti