Мне нужно получить сообщение из SOAP и сохранить их в базе данных MySQL в Mule.Вставить мыло в базу данных в mulesoft
Я использую набор переменных, чтобы получить текст, я хочу:
#[xpath('//tra:sayHi/ID/text()').getText()]
Тогда в компоненте Database, я использую это:
insert into account(id,name,REF1,REF2) values(#[flowVars.ID],#[flowVars.name],null,null)
Когда я проверяю в SoapUI, я получил ниже сообщение об ошибке:
org.apache.cxf.interceptor.Fault: не удалось найти трансформатор для преобразования "SimpleDataType {type = java.lang.Integer, mimeType = 'text/xml'}" в "SimpleDataType {type = javax.xml .stream.XMLStreamReader, м imeType = '/'} ".
Мой XML является:
<?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>
При проверке базы данных, запись была вставлена. Я просто не знаю, почему есть сообщение об ошибке. Спасибо за любую помощь.
Можете ли вы приложить xml, посланный soapUI, пожалуйста? –