I need to get the message from SOAP and save them to a MySQL database in Mule.
I use set variable to get the text I want:
#[xpath('//tra:sayHi/ID/text()').getText()]
Then in Database component, I use this:
insert into account(id,name,REF1,REF2) values(#[flowVars.ID],#[flowVars.name],null,null)
When I test in SoapUI, I got below error message:
org.apache.cxf.interceptor.Fault: Could not find a transformer to transform "SimpleDataType{type=java.lang.Integer, mimeType='text/xml'}" to "SimpleDataType{type=javax.xml.stream.XMLStreamReader, mimeType='/'}".
My XML is:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" 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" version="EE-3.5.2"
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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.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/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd">
<mulexml:namespace-manager>
<mulexml:namespace prefix="soapenv"
uri="http://schemas.xmlsoap.org/soap/envelope/"/>
<mulexml:namespace prefix="tra"
uri="http://training/"/>
</mulexml:namespace-manager>
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="admin" password="pontiac" database="sqwarepeg" doc:name="MySQL Configuration"/>
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP"/>
<cxf:proxy-service port="SF2DBPort" namespace="http://training/" service="SF2DBService" payload="body" wsdlLocation="/src/main/resources/SF2DB.wsdl" doc:name="CXF"/>
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<set-variable variableName="name" value="#[xpath('//tra:sayHi/name/text()').getText()]" doc:name="Set name"/>
<set-variable variableName="ID" value="#[xpath('//tra:sayHi/ID/text()').getText()]" doc:name="set ID"/>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[insert into account(id,name,REF1,REF2) values(#[flowVars.ID],#[flowVars.name],null,null)]]></db:parameterized-query>
</db:insert>
<logger message="The reply "#[flowVars.ID]" means "Customer ID"" level="INFO" doc:name="Logger"/>
</flow>
</mule>
When I check the Database, the record has been inserted. I just don't know why there is the error message. Thanks for any help.