从 xml 转换为对象时出现此异常。“cardHolder (com.thoughtworks.xstream.mapper.CannotResolveClassException)” 我的课程如下:
@XmlRootElement
public class CardHolder {
String transactionType;
String cardNumber;
//cons..
//getters and setters
}
为了转换 Jersey 响应,您需要提取实体,因为它由 MuleResponseWriter 包装。
http://www.mulesoft.org/documentation/display/current/Jersey+Module+Reference
来自文档:ContainerResponse cr = (ContainerResponse)
message.getInvocationProperty("jersey_response"); String messageString = (String) cr.getResponse().getEntity(); message.setPayload(messageString);
您可以使用它创建一个自定义转换器,或者您可以创建一个类似于以下内容的简单脚本转换器并将其放在您的 xml-to-object 转换器之前:
<!-- Should be MuleResponseWriter -->
<logger level="INFO" message="Payload after jersey resource: #[payload]" />
<scripting:transformer>
<scripting:script engine="groovy">
<scripting:text><![CDATA[
import com.sun.jersey.spi.container.ContainerResponse;
ContainerResponse cr = (ContainerResponse)flowVars['jersey_response'];
message.setPayload(cr.getResponse().getEntity());
]]></scripting:text>
</scripting:script>
</scripting:transformer>
<!-- What type? -->
<logger level="INFO" message="Payload after script: #[payload]" />