Search code examples
javasipuser-presencesip-servlet

SIP Servlets: SipServletRequest getcontent as xml


I am doing a POC on SIP SIMPLE using SIP Servlets APIs.

In publish request I want to read the contents of the published XML. I know the content type of the request is application/pidf+xml. But I am not able to convert it to XML, I don't know which class handles this and when I try to find out the class name of the object it also returns some value like [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());
    }

Please tell me how to convert the returned object to the XML. I am really struggling to find the proper way.

Thanks

My Solution: Don't know if this is a solution or a workaround but below is what I have done:

byte[] o = (byte[]) req.getContent();
String s = new String(o);
System.out.println("Class type "+s);

so, s now has XML string which can be converted to XML.

If there is some better solution please do post.

Thanks


Solution

  • Don't know if this is a solution or a workaround but below is what I have done:

    byte[] o = (byte[]) req.getContent();
    String s = new String(o);
    System.out.println("Class type "+s);
    

    so, s now has XML string which can be converted to XML.

    If there is some better solution please do post.

    Thanks