This discussion is archived
2 Replies Latest reply: Jun 17, 2008 5:20 AM by 843853 RSS

JAIN: SIP Message to SIP Application Server

843853 Newbie
Currently Being Moderated
Hey guys,

I have been trying to implement a simple application that send an INVITE message to a SIP Application Server.

The code I am using to create and send the INVITE message is as follows:
public void sendMessage(String to, String message) throws ParseException,
         InvalidArgumentException, SipException {

        //FROM Header
     SipURI from = addressFactory.createSipURI(getUsername(), getHost() + ":" + getPort());
     Address fromNameAddress = addressFactory.createAddress(from);
     fromNameAddress.setDisplayName(getUsername());
     FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress,     "textclientv1.0");

     //TO Header
     String username = to.substring(to.indexOf(":") + 1, to.indexOf("@"));     
     String address = to.substring(to.indexOf("@") + 1);
     SipURI toAddress = addressFactory.createSipURI(username, address);
     Address toNameAddress = addressFactory.createAddress(toAddress);
     toNameAddress.setDisplayName(username);
     ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);

     //VIA Header
     SipURI requestURI = addressFactory.createSipURI(username, address);
     requestURI.setTransportParam("udp");
     ArrayList viaHeaders = new ArrayList();
     ViaHeader viaHeader = headerFactory.createViaHeader(getHost(), getPort(), "udp", "branch1");
     viaHeaders.add(viaHeader);

     //CALLID Header
     CallIdHeader callIdHeader = sipProvider.getNewCallId();

     //CSEQ Header
     CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1, Request.INVITE);

     //MAXFORWARD Header
     MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(70);

     Request request = messageFactory.createRequest(requestURI, Request.INVITE, callIdHeader, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwards);

     SipURI contactURI = addressFactory.createSipURI(getUsername(), getHost());
     contactURI.setPort(getPort());
     Address contactAddress = addressFactory.createAddress(contactURI);
     contactAddress.setDisplayName(getUsername());
     ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
     request.addHeader(contactHeader);
     

     ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("text", "plain");
     request.setContent(message, contentTypeHeader);

     
     sipProvider.sendRequest(request);

    }
Now my question is how do I get this request to be sent to the SIP A/S? I passed "sip:admin@192.168.2.15" where:

The SIP A/S is on: 192.168.15

as my "String to" parameter for this function but my SIP A/S does not seem to receive any kind of message from my application.

Any help or direction towards help would be greatly appreciated.

Thank you!