将soap消息插入mulesoft中的数据库

时间:2015-01-22 05:25:22

标签: mule

我需要从SOAP获取消息并将它们保存到Mule中的MySQL数据库。

我使用set变量来获取我想要的文字:

#[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,mimeType =' / '}“。

我的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 &quot;#[flowVars.ID]&quot; means &quot;Customer ID&quot;" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

当我检查数据库时,已插入记录。我只是不知道为什么会出现错误信息。谢谢你的帮助。

1 个答案:

答案 0 :(得分:0)

您的流程中缺少重要的一点:没有set-payload消息处理器来设置响应对象cxf:proxy-service将序列化为有效的SOAP响应。