@Test public void testTextToXML() throws JsonProcessingException { TextXmlMessage textXmlMessage = new TextXmlMessage(); textXmlMessage.setContent("content"); textXmlMessage.setFromUser("from user"); textXmlMessage.setToUser("to user"); textXmlMessage.setCreateTime(new Date()); String xml = QyXmlMessages.toXml(textXmlMessage); Assert.assertTrue(xml.contains("<ToUserName><![CDATA[to user]]></ToUserName>")); Assert.assertTrue(xml.contains("<FromUserName><![CDATA[from user]]>")); Assert.assertTrue(xml.contains("<MsgType><![CDATA[text]]></MsgType>")); Assert.assertTrue(xml.contains("<Content><![CDATA[content]]></Content>")); }
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()); } }
QyXmlMessages { 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()); } } }
QyXmlMessages { 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()); } }  }
QyXmlMessages { 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); }
QyXmlMessages { 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);  }