应该采取哪些措施?什么应该出现在司机类?我应该如何创建用于映射XML的POJO?我该如何配置变压器?
答案 0 :(得分:2)
你可以使用像Xpp3driver
这样的驱动程序类例如。
流程看起来像
<flow name="mulexmlvalFlow2" doc:name="mulexmlvalFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP" path="XmlToObj"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object" driverClass="com.thoughtworks.xstream.io.xml.Xpp3Driver">
<mulexml:alias name="Abc" class="a.b.c.Abc" />
</mulexml:xml-to-object-transformer>
<component class="Test1" doc:name="Java"/>
</flow>
http请求
http://localhost:8082/XmlToObj
头 Content-Type application / xml 发布数据
<Abc><def>ggggg</def><ghi>hhhhh</ghi></Abc>
ABC班
package a.b.c.Abc;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "Abc")
public class Abc{
private String def;
private String ghi;
public Abc() {
}
public String getDef() {
return def;
}
public void setDef(String def) {
this.def = def;
}
public String getGhi() {
return ghi;
}
public void setGhi(String ghi) {
this.ghi = ghi;
}
}
Class Test1(组件)
public class Test1 {
public Object receive(Abc abc) throws Exception {
System.out.println(abc);
return "Success";
}
}