我在收到这样的邀请时尝试触发注册请求:
SipURI fromToURI = sipFactory.createSipURI(userName, domainName);
//using the invite request to make a register request
SipServletRequest sipServletRequest = sipFactory.createRequest(request.getApplicationSession(), "REGISTER", fromToURI, fromToURI);
sipServletRequest.setHeader("Expires", "3600");
sipServletRequest.setHeader("User-Agent", "mobicentsWSSclient");
SipURI requestURI = sipFactory.createSipURI("myroutablewssproxy.com", domainName);
//.setPort();
requestURI.setTransportParam("wss");
requestURI.setPort(8443);
try {
Parameterable parameterable = sipServletRequest.getParameterableHeader("Contact");
parameterable.setParameter("expires", "0");
} catch (ServletParseException e1) {
logger.error("Impossible to set the expires on the contact header",e1);
}
try {
sipServletRequest.setRequestURI(requestURI);
sipServletRequest.send();
} catch (IOException e) {
logger.error("An unexpected exception occured while sending the REGISTER request",e);
}
但是在尝试访问联系人标头时出现空指针异常。如果我不尝试访问联系人标头,则注册请求完全缺少联系人标头,因此注册尝试失败。有没有办法访问 servlet 上下文并在此注册请求中使用它的联系信息?