我正在使用 SIP Servlets API 在 SIP SIMPLE 上进行 POC。
在发布请求中,我想阅读已发布 XML 的内容。我知道请求的内容类型是application/pidf+xml。但我无法将其转换为 XML,我不知道哪个类处理这个问题,当我尝试找出对象的类名时,它也返回一些值,如[B。
protected void doPublish(SipServletRequest req) throws ServletException,
IOException {
// TODO Auto-generated method stub
super.doPublish(req);
Object o = req.getContent();
System.out.println("ContentType "+req.getContentType());
System.out.println("Class "+o.getClass().getName());
}
请告诉我如何将返回的对象转换为 XML。我真的很难找到正确的方法。
谢谢
我的解决方案: 不知道这是解决方案还是解决方法,但以下是我所做的:
byte[] o = (byte[]) req.getContent();
String s = new String(o);
System.out.println("Class type "+s);
所以,s现在有了可以转换为 XML 的 XML 字符串。
如果有更好的解决方案,请发帖。
谢谢