/** Initialize the message using the properties in the MessageProps. */
  public void initializeMessage() throws Exception {

    if (!(this.properties instanceof EBMSMessageData))
      throw new ClassCastException("Invalid EBMS Message class data");
    EBMSMessageData d = (EBMSMessageData) this.properties;
    this.addRequestElementText("messageId", d.getMessageIdForReceive(), NS_PREFIX, NS_URI);
  }
  public EBMSMessageReceiver(FileLogger l, EBMSMessageData m) {
    super(l, m);
    EBMSMessageData d = (EBMSMessageData) m;

    this.messageId = d.getMessageIdForReceive();

    // Setup the receiver config.
    this.setLoopTimes(1);
    this.setServiceEndPoint(d.getRecvEndpoint());
  }
  public static void main(String[] args) {
    try {
      if (args.length < 3) {
        System.out.println("Usage: ebms-recv [config-xml] [log-path] [output folders] ");
        System.out.println();
        System.out.println(
            "Example: ebms-recv "
                + "./config/ebms-recv/ebms-request.xml "
                + "./logs/ebms-recv.log "
                + "./output/ebms-recv/ ");
        System.exit(1);
      }
      System.out.println("----------------------------------------------------");
      System.out.println("       EBMS Message Receiver           ");
      System.out.println("----------------------------------------------------");

      // Initalize the logger.
      System.out.println("Initialize Logger ... ");
      FileLogger logger = new FileLogger(new java.io.File(args[1]));

      // Initialize the query parameter.
      System.out.println("Importing  ebMS sending parameters ... " + args[0]);
      EBMSMessageData requestData =
          DataFactory.getInstance()
              .createEBMSMessageDataFromXML(
                  new PropertyTree(new java.io.File(args[0]).toURI().toURL()));

      // Initalize the receiver client for downloading available message.
      System.out.println("Initialize ebMS message receiver... ");
      EBMSMessageReceiver recvSender = new EBMSMessageReceiver(logger, requestData);
      recvSender.setOutputDirectory(args[2]);

      System.out.println(
          "Sending  ebMS receiving request ... for " + requestData.getMessageIdForReceive());
      recvSender.run();
      System.out.println();

      System.out.println("----------------------------------------------------");
      System.out.println();
      System.out.println("Please view logs for details .. ");
    } catch (Exception e) {
      e.printStackTrace(System.err);
    }
  }