Mule中的DataMapper未返回所需的输出

时间:2013-07-02 06:49:30

标签: mule-studio

我是Mule的新手,只是尝试使用mule来公开SOAP webservice。我使用了以下来自mule soft http://www.mulesoft.org/documentation/display/current/XML-only+SOAP+Web+Service+Example的例子。我能够公开webservice,但是当DataMapper组件尝试将Data从一个请求映射到另一个请求时会出现错误。附加文件包含所需的配置。当我使用Mule Studio中的预览选项卡在mapper上运行测试xml时,它只返回:并且表示您的XML无效。错误:文件过早结束。

请建议。

以下是配置:

    <?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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.3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
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/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd ">
    <data-mapper:config name="admitToUpsert" transformationGraphPath="admittoupsert.grf" doc:name="DataMapper"/>
    <flow name="admitPatientService" doc:name="admitPatientService">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" doc:name="AdmissionService"/>
        <cxf:proxy-service port="AdmissionPort" namespace="http://www.mule-health.com/SOA/service/admission/1.0" service="AdmissionService" payload="body" doc:name="Proxy Service" wsdlLocation="service/AdmissionService.wsdl"/>
        <logger message="First request: #[message.payload]" level="INFO" doc:name="Logger"/>
        <mulexml:dom-to-xml-transformer doc:name="Object to XML" returnClass="java.lang.String"/>
        <logger message="Before hiting transfomer: #[message.payload]" level="INFO" doc:name="Logger"/>
        <data-mapper:transform config-ref="admitToUpsert" doc:name="DataMapper"/>
        <byte-array-to-string-transformer returnClass="java.lang.String" mimeType="text/plain" doc:name="Byte Array to String"/>
        <logger message="Upsert Request is: #[message]" level="INFO" doc:name="Logger"/>
    </flow>
</mule>

以下是Test xml:

<ns0:admitSubject xmlns:ns0="http://www.mule-health.com/SOA/service/admission/1.0" xmlns:ns1="http://www.mule-health.com/SOA/model/1.0">
     <ns1:Referer>
        <ns1:clientId>7899</ns1:clientId>
     </ns1:Referer>
     <ns1:Referral>
        <ns1:procedure>
           <ns1:code>In-patient</ns1:code>
           <ns1:admission>Elective</ns1:admission>
           <ns1:department>CARDIOLOGY</ns1:department>
        </ns1:procedure>
     </ns1:Referral>
     <ns1:Subject>
        <ns1:nationalId>4657</ns1:nationalId>
        <ns1:firstName>Charles</ns1:firstName>
        <ns1:lastName>Brown</ns1:lastName>
        <ns1:address1>Any Street</ns1:address1>
        <ns1:address2>?</ns1:address2>
        <ns1:address3>?</ns1:address3>
        <ns1:nationality>American</ns1:nationality>
        <ns1:gender>Male</ns1:gender>
        <ns1:dateOfBirth>1987-01-19</ns1:dateOfBirth>
     </ns1:Subject>
  </ns0:admitSubject>

WSDL和XSD可以从https://github.com/mulesoft/Pre-sales-hospital-admission/tree/master/src/main/resources/service中提取。抱歉没有粘贴它,因为它会导致页面上的大量数据,但我可以在需要时添加它们

1 个答案:

答案 0 :(得分:0)

我能够解决这个问题。当复制粘贴xml时,似乎有些特殊字符被淹没了。当我在Mule studio中从XSD生成XML时,它运行良好。

相关问题