当我使用mulesoft调用带有“clob”的存储过程作为数据类型将xml数据插入数据库时,我面临此异常,它在oracle上显示异常。 这是我的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc"
xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
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.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/sfdc http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
<flow name="opp_to_sales_orderFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="/opportunity" doc:name="HTTP"/>
<sfdc:query config-ref="Salesforce__Basic_Authentication" query="SELECT Id, Product_Name__c, Account.name FROM Opportunity " doc:name="Salesforce"/>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/xml skipNullOn="everywhere"
---
list: { (payload map {
linked-hash-map : {
name:$.Account.Name,
id: $.Id,
Product_name: $.Product_Name__c
}
})
}
]]></dw:set-payload>
</dw:transform-message>
<logger level="INFO" doc:name="Logger" message="#[payload]"/>
<byte-array-to-string-transformer encoding="UTF-8" mimeType="application/xml" doc:name="Byte Array to String"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[call xxnew_order_create.xxenv_order_creation8(
:p_mule_input,
:x_order_cursor
:x_error_code, :x_error_message,
:x_sales_order
)]]></db:parameterized-query>
<db:in-param name="p_mule_input" type="LONGVARCHAR" value="#[message.payload]"/>
<db:out-param name="x_order_cursor" type="CURSOR"/>
<db:out-param name="x_sales_order" type="VARCHAR"/>
<db:out-param name="x_error_code" type="VARCHAR"/>
<db:out-param name="x_error_message" type="VARCHAR"/>
</db:stored-procedure>
<dw:transform-message doc:name="Transform Message">
<dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload]]></dw:set-payload>
</dw:transform-message>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
<catch-exception-strategy doc:name="Exception Handling ">
<logger level="INFO" doc:name="StartLog"/>
<set-payload value="{ "errorMessage" : "#[exception.message]", "exception":"#[exception.getDetailedMessage()]" }" encoding="UTF-8" mimeType="text/html" doc:name="Catch Exception"/>
<set-property propertyName="http.status" value="400" doc:name="http.status"/>
<logger level="INFO" doc:name="EndLog"/>
</catch-exception-strategy>
</flow>
</mule>
谢谢
答案 0 :(得分:0)
请粘贴您的配置文件,因为类型转换是在作为clob传递之前,您需要的数据是字符串格式。
答案 1 :(得分:0)
请尝试使用groovy组件并添加如下代码。
clobTest = (java.sql.Clob)payload.your_field bodyText = clobTest.getCharacterStream() targetString = org.apache.commons.io.IOUtils.toString(bodyText) payload.PAYLOADHEADERS=targetString return payload
答案 2 :(得分:0)
逗号,现在它的工作正常,感谢您的回复