0

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

user3275095
  • 1,605
  • 4
  • 24
  • 36

1 Answers1

0

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

user3275095
  • 1,605
  • 4
  • 24
  • 36
  • This is a good start, but for a general solution, you'll need to scrub any MIME headers before you get the XML, and if it's multipart with SDP, you'll also need to scrub the SDP part which might come before the PIDF – lreeder Sep 13 '15 at 17:37