@Test public void testVideoToXML() throws JsonProcessingException { VideoXmlMessage videoXmlMessage = new VideoXmlMessage(); Video video = new Video(); video.setMediaId("video media id"); video.setTitle("title"); video.setDescription("desc"); videoXmlMessage.setVideo(video); videoXmlMessage.setFromUser("from user"); videoXmlMessage.setToUser("to user"); videoXmlMessage.setCreateTime(new Date()); String xml = MpXmlMessages.toXml(videoXmlMessage); Assert.assertTrue(xml.contains("<ToUserName><![CDATA[to user]]></ToUserName>")); Assert.assertTrue(xml.contains("<FromUserName><![CDATA[from user]]>")); Assert.assertTrue(xml.contains("<MsgType><![CDATA[video]]></MsgType>")); Assert.assertTrue(xml.contains("<Video><MediaId><![CDATA[video media id]]></MediaId><Title><![CDATA[title]]></Title><Description><![CDATA[desc]]></Description></Video>")); }
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);  }