Question

I need to get the extension number from the "From header", I have tried everything but nothing worked.

Even tried to do:

byte[] raw = req.getRawContent();

And manually find the From and the number, But that returned null

What am I doing wrong? How to get that number

Was it helpful?

Solution

Get the FromHeader and then extract the information you need from it. For instance, if the extension is the user part of the URI:

FromHeader fromHeader = (FromHeader) req.getHeader("From");
Address fromAddress = fromHeader.getAddress();
URI fromURI = fromAddress.getURI();
if (fromURI.isSipURI()) {
  SipURI fromSipURI = (SipURI) fromURI;
  extension = fromSipURI.getUser();
}

OTHER TIPS

Did you saw the javadoc?

The method getRawContent() return a message content as a raw byte array, or null if no content is set

Can you explain again your question? Maybe I can help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top