2 Replies Latest reply: Jun 17, 2008 7:20 AM by 843853 RSS

    JAIN: SIP Message to SIP Application Server

      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);
           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);
           ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);
           //VIA Header
           SipURI requestURI = addressFactory.createSipURI(username, address);
           ArrayList viaHeaders = new ArrayList();
           ViaHeader viaHeader = headerFactory.createViaHeader(getHost(), getPort(), "udp", "branch1");
           //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());
           Address contactAddress = addressFactory.createAddress(contactURI);
           ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
           ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("text", "plain");
           request.setContent(message, contentTypeHeader);
      Now my question is how do I get this request to be sent to the SIP A/S? I passed "sip:admin@" 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!