@Test public void testKfMessageToXML() throws JsonProcessingException { Forward2CareXmlMessage kfXmlMessage = new Forward2CareXmlMessage(); kfXmlMessage.setFromUser("from user"); kfXmlMessage.setToUser("to user"); kfXmlMessage.setCreateTime(new Date()); String xml = MpXmlMessages.toXml(kfXmlMessage); Assert.assertTrue(xml.contains("<ToUserName><![CDATA[to user]]></ToUserName>")); Assert.assertTrue(xml.contains("<FromUserName><![CDATA[from user]]>")); kfXmlMessage.setAccount("kfaccount"); xml = MpXmlMessages.toXml(kfXmlMessage); Assert.assertTrue(xml.contains("<TransInfo><KfAccount><![CDATA[kfaccount]]></KfAccount>")); }
public static String toXml(XmlMessageHeader xmlMessage) { try { return XmlObjectMapper.defaultMapper().toXml(xmlMessage); } catch (JsonProcessingException e) { logger.error("message to xml failed", e); throw new WxRuntimeException(999, "message to xml failed," + e.getMessage()); } }
MpXmlMessages { public static String toXml(XmlMessageHeader xmlMessage) { try { return XmlObjectMapper.defaultMapper().toXml(xmlMessage); } catch (JsonProcessingException e) { logger.error("message to xml failed", e); throw new WxRuntimeException(999, "message to xml failed," + e.getMessage()); } } }
MpXmlMessages { public static String toXml(XmlMessageHeader xmlMessage) { try { return XmlObjectMapper.defaultMapper().toXml(xmlMessage); } catch (JsonProcessingException e) { logger.error("message to xml failed", e); throw new WxRuntimeException(999, "message to xml failed," + e.getMessage()); } }  }
MpXmlMessages { public static String toXml(XmlMessageHeader xmlMessage) { try { return XmlObjectMapper.defaultMapper().toXml(xmlMessage); } catch (JsonProcessingException e) { logger.error("message to xml failed", e); throw new WxRuntimeException(999, "message to xml failed," + e.getMessage()); } }  static XmlMessageHeader fromXml(String xml); static String toXml(XmlMessageHeader xmlMessage); }
MpXmlMessages { public static String toXml(XmlMessageHeader xmlMessage) { try { return XmlObjectMapper.defaultMapper().toXml(xmlMessage); } catch (JsonProcessingException e) { logger.error("message to xml failed", e); throw new WxRuntimeException(999, "message to xml failed," + e.getMessage()); } }  static XmlMessageHeader fromXml(String xml); static String toXml(XmlMessageHeader xmlMessage);  }