public SIPResponse createResponse(int statusCode,String reasonPhrase){
  SIPResponse newResponse;
  newResponse=new SIPResponse();
  try {
    newResponse.setStatusCode(statusCode);
  }
 catch (  ParseException ex) {
    throw new IllegalArgumentException("Bad code " + statusCode);
  }
  if (reasonPhrase != null)   newResponse.setReasonPhrase(reasonPhrase);
 else   newResponse.setReasonPhrase(SIPResponse.getReasonPhrase(statusCode));
  for (  String headerName : headersToIncludeInResponse) {
    SIPHeader nextHeader=headerTable.get(headerName);
    if (nextHeader != null) {
      if (!(nextHeader instanceof RecordRouteList) || (nextHeader instanceof RecordRouteList && mustCopyRR(statusCode))) {
        try {
          newResponse.attachHeader((SIPHeader)nextHeader.clone(),false);
        }
 catch (        SIPDuplicateHeaderException e) {
          e.printStackTrace();
        }
      }
    }
  }
  if (MessageFactoryImpl.getDefaultServerHeader() != null) {
    newResponse.setHeader(MessageFactoryImpl.getDefaultServerHeader());
  }
  ServerHeader server=MessageFactoryImpl.getDefaultServerHeader();
  if (server != null) {
    newResponse.setHeader(server);
  }
  return newResponse;
}

public SIPResponse createResponse ( int statusCode , String reasonPhrase ) { SIPResponse newResponse ; newResponse = new SIPResponse ( ) ; try { newResponse . setStatusCode ( statusCode ) ; } catch ( ParseException ex ) { throw new IllegalArgumentException ( "Bad code " + statusCode ) ; } if ( reasonPhrase != null ) newResponse . setReasonPhrase ( reasonPhrase ) ; else newResponse . setReasonPhrase ( SIPResponse . getReasonPhrase ( statusCode ) ) ; for ( String headerName : headersToIncludeInResponse ) { SIPHeader nextHeader = headerTable . get ( headerName ) ; if ( nextHeader != null ) { if ( ! ( nextHeader instanceof RecordRouteList ) || ( nextHeader instanceof RecordRouteList && mustCopyRR ( statusCode ) ) ) { try { newResponse . attachHeader ( ( SIPHeader ) nextHeader . clone ( ) , false ) ; } catch ( SIPDuplicateHeaderException e ) { e . printStackTrace ( ) ; } } } } if ( MessageFactoryImpl . getDefaultServerHeader ( ) != null ) { newResponse . setHeader ( MessageFactoryImpl . getDefaultServerHeader ( ) ) ; } ServerHeader server = MessageFactoryImpl . getDefaultServerHeader ( ) ; if ( server != null ) { newResponse . setHeader ( server ) ; } return newResponse ; }
creates a default sipresponse message for this request . note you must add the necessary tags to outgoing responses if need be . for efficiency , this method does not clone the incoming request . if you want to modify the outgoing response , be sure to clone the incoming request as the headers are shared and any modification to the headers of the outgoing response will result in a modification of the incoming request . tag fields are just copied from the incoming request . contact headers are removed from the incoming request . added by jeff keyser . route headers are not added to the response .
