I also convert the msgId into a string, as Dennis suggested.

If interested, in Java, I use the 1st method below to convert the byte array to a string, and the 2nd to convert back from a string.
Regards,
Alan

  /**
   * Converts a array of bytes into hexadecimal string representation.
   *
   * @param byteArray a byte array
   * @return a <code>String</code>.
   */
  public static String toHexString(byte[] byteArray) {
    StringBuffer buffer = new StringBuffer();

    for (int i = 0; i < byteArray.length; i++) {
      buffer.append(Integer.toHexString((byteArray[i] >> 4) & 0xf));
      buffer.append(Integer.toHexString((byteArray[i]) & 0xf));
    }

    return buffer.toString();
  }

  /**
   * Converts a hex string to a byte array.
   * Permits upper or lower case hex.
   *
   * @param hexString String must have even number of characters.
   * and be formed only of digits 0-9 A-F or
   * a-f. No spaces, minus or plus signs.
   * @return corresponding byte array.
   */
  public static byte[] fromHexString(String hexString) {
    int stringLength = hexString.length();

    if ((stringLength & 0x1) != 0) {
      throw new IllegalArgumentException();
    }

    byte[] byteArray = new byte[stringLength / 2];

    for (int i = 0, j = 0; i < stringLength; i += 2, j++) {
      int high = charToNibble(hexString.charAt(i));
      int low = charToNibble(hexString.charAt(i + 1));
      byteArray[j] = (byte) ((high << 4) | low);
    }

    return byteArray;
  }

  /**
   * Converts a single char to corresponding nibble.
   *
   * @param c char to convert. must be 0-9 a-f A-F, no
   * spaces, plus or minus signs.
   * @return corresponding integer
   */
  private static int charToNibble(char c) {
    if ('0' <= c && c <= '9') {
      return c - '0';
    } else if ('a' <= c && c <= 'f') {
      return c - 'a' + 0xa;
    } else if ('A' <= c && c <= 'F') {
      return c - 'A' + 0xa;
    } else {
      throw new IllegalArgumentException("Invalid hex character: " + c);
    }
  }



"Miller, Dennis" <[EMAIL PROTECTED]>
Sent by: MQSeries List <[EMAIL PROTECTED]>

21/11/2002 06:47 AM
Please respond to MQSeries List

       
        To:        [EMAIL PROTECTED]
        cc:        
        Subject:        Re: MQMQ MsgID - valid characters



You should not pass the msgid in XML without converting it to a string
first. You could do like JMS and convert each half-byte to the single text
character used in hex notation, i.e. "0"-"F".  Of course, msgid is then
transported in 48 bytes, which needs to be reversed at the other end.

> -----Original Message-----
> From: Pope, Ben [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, November 20, 2002 8:36 AM
> To:   [EMAIL PROTECTED]
> Subject:      MQMQ MsgID - valid characters
>
>
> I have a situation where I need to pass the MsgId contents as part of an
> XML message.
> What I've found in the docs describes how the field in constructed by the
> queue manger
> but it is described as being simply "a byte field".  Are there any details
> as to what byte
> range could be used?  Specifically, codes between 0x00 and 0x20 are
> considered invalid
> XML and if they can be included in the MsgId field then I need to account
> for that
> possibility.
>
> Thanks, Ben
>

Instructions for managing your mailing list subscription are provided in
the Listserv General Users Guide available at http://www.lsoft.com
Archive: http://vm.akh-wien.ac.at/MQSeries.archive


------------------------------------------------------------------------This email is 
intended for the named recipient only. The informationcontained in this message may be 
confidential, or commerciallysensitive. If you are not the intended recipient you must 
not reproduceor distribute any part of the email, disclose its contents to any 
otherparty, or take any action in reliance on it. If you have received thisemail in 
error, please contact the sender immediately.  Please deletethis message from your 
computer.------------------------------------------------------------------------


Reply via email to