MULE Esb xml to Object transformer


Я пытаюсь использовать xml to object transformer в mule при передаче полезной нагрузки xml в Java Bean (Customer). Вот мой простой поток. Исключение, которое я вижу, находится ниже

Exception stack is:
1. CUSTOMER (com.thoughtworks.xstream.mapper.CannotResolveClassException)
  com.thoughtworks.xstream.mapper.DefaultMapper:56 (null)
2. CUSTOMER (com.thoughtworks.xstream.mapper.CannotResolveClassException) (org.mule.api.transformer.TransformerException)
  org.mule.module.xml.transformer.XmlToObject:76 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
com.thoughtworks.xstream.mapper.CannotResolveClassException: CUSTOMER
    at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:56)
    at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
    at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

поток

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

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" 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.4.1" 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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd">
    <flow name="alternateFlow1" doc:name="alternateFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8999" doc:name="HTTP"/>
        <http:outbound-endpoint exchange-pattern="request-response" host="www.thomas-bayer.com" port="80" path="sqlrest/CUSTOMER/3/" method="GET" doc:name="HTTP"/>
        <mulexml:xml-to-object-transformer returnClass="com.abc.dto.CUSTOMER" doc:name="XML to Object"/>
        <logger level="INFO" doc:name="Logger"/>
    </flow>
</mule>

XML:

<CUSTOMER xmlns:xlink="w3.org/1999/xlink">
 ;
 <ID>4</ID>
 <FIRSTNAME>Sylvia</FIRSTNAME>
 <LASTNAME>Ringer</LASTNAME>
 <STREET>365 College Av.</STREET>
 <CITY>Dallas</CITY>
</CUSTOMER>
1 3
esb

1 ответ:

Вам нужно добавить псевдоним в mulexml:xml-to-object-transformer:

<mulexml:alias name="CUSTOMER" class="com.abc.dto.CUSTOMER" />

Кроме того, нет никаких причин идти все заглавные буквы с именем класса, поэтому переименуйте свой класс и псевдоним его:

<mulexml:alias name="CUSTOMER" class="com.abc.dto.Customer" />