// create >From Header
SipURI fromAddress = addressFactory.createSipURI(
fromName, fromSipAddress);
Address fromNameAddress = addressFactory
.createAddress(fromAddress);
fromNameAddress.setDisplayName(fromDisplayName);
FromHeader fromHeader = headerFactory
.createFromHeader(fromNameAddress, "12345");
// create To Header
SipURI toAddress = addressFactory.createSipURI(
toUser, toSipAddress);
Address toNameAddress = addressFactory
.createAddress(toAddress);
toNameAddress.setDisplayName(toDisplayName);
ToHeader toHeader = headerFactory.createToHeader(
toNameAddress, null);
// create Request URI
String peerHostPort = peerHost + ":" + peerPort;
SipURI requestURI = addressFactory.createSipURI(
toUser, peerHostPort);
// Create ViaHeaders
ArrayList viaHeaders = new ArrayList();
ViaHeader viaHeader = headerFactory
.createViaHeader(host, sipProvider.getListeningPoint(
transport).getPort(),
transport, null);
// add via headers
viaHeaders.add(viaHeader);
SipURI sipuri = addressFactory.createSipURI(null,
host);
sipuri.setPort(peerPort);
sipuri.setLrParam();
RouteHeader routeHeader = headerFactory
.createRouteHeader(addressFactory
.createAddress(sipuri));
// Create ContentTypeHeader
ContentTypeHeader contentTypeHeader = headerFactory
.createContentTypeHeader("application", "sdp");
// Create a new CallId header
CallIdHeader callIdHeader = sipProvider.getNewCallId();
// JvB: Make sure that the implementation matches the messagefactory
callIdHeader = headerFactory
.createCallIdHeader(callIdHeader.getCallId());
// Create a new Cseq header
CSeqHeader cSeqHeader = headerFactory
.createCSeqHeader(1L, Request.INVITE);
// Create a new MaxForwardsHeader
MaxForwardsHeader maxForwards = headerFactory
.createMaxForwardsHeader(70);
// Create the request.
Request request = messageFactory.createRequest(
requestURI, Request.INVITE, callIdHeader, cSeqHeader,
fromHeader, toHeader, viaHeaders, maxForwards);
// Create contact headers
SipURI contactUrl = addressFactory.createSipURI(
fromName, host);
contactUrl.setPort(listeningPoint.getPort());
// Create the contact name address.
SipURI contactURI = addressFactory.createSipURI(
fromName, host);
contactURI.setPort(sipProvider.getListeningPoint(
transport).getPort());
contactURI.setTransportParam(transport);
Address contactAddress = addressFactory
.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(fromName);
contactHeader = headerFactory
.createContactHeader(contactAddress);
request.addHeader(contactHeader);