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, new Integer((int) (Math
.random() * Integer.MAX_VALUE)).toString());
// 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 addressed to me
SipURI requestURI = protocolObjects.addressFactory.createSipURI(
toUser, Shootme.myAddress + ":" + Shootme.myPort);
// Create ViaHeaders
ArrayList viaHeaders = new ArrayList();
int port = provider.getListeningPoint(protocolObjects.transport)
.getPort();
ViaHeader viaHeader = protocolObjects.headerFactory
.createViaHeader(myAddress, port,
protocolObjects.transport, null);
// add via headers
viaHeaders.add(viaHeader);
// Create ContentTypeHeader
ContentTypeHeader contentTypeHeader = protocolObjects.headerFactory
.createContentTypeHeader("application", "sdp");
// Create a new CallId header
CallIdHeader callIdHeader = provider.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
// Create the contact name address.
SipURI contactURI = protocolObjects.addressFactory.createSipURI(
fromName, myAddress);
contactURI.setPort(provider.getListeningPoint(
protocolObjects.transport).getPort());
Address contactAddress = protocolObjects.addressFactory
.createAddress(contactURI);