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