« Return to Thread: Passing base62binary through OpenMQ, what form does the data return in?

Passing base62binary through OpenMQ, what form does the data return in?

by jsexton0 :: Rate this Message:

Reply to Author | View in Thread

Hello -

I'm having a lot of trouble decoding some bytes that have passes through an MQ as an attachment.  Hopefully there is a simple answer to this.  Consider this XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.iwsinc.com/schema/msg/MsgQMessage"
    xmlns:IWS="http://www.iwsinc.com/schema/msg/MsgQMessage"
    xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
    elementFormDefault="qualified">
    <xsd:import schemaLocation="xmlmime.xsd" namespace="http://www.w3.org/2005/05/xmlmime"/>
    <xsd:complexType name="MsgQMessageType">
        <xsd:sequence>
            <xsd:element name="SchemaVersion" type="IWS:schemaVersionNo"/>
            <xsd:element name="AppRequestID" type="xsd:string"/>
            <xsd:element name="Topic" type="xsd:string"/>
            <xsd:element name="Source" type="xsd:string"/>
            <xsd:choice>

                <!-- Here are the bytes in question -->
                <xsd:element name="MsgData" type="xmime:base64Binary"/>

                <xsd:element name="MsgURI" type="xsd:anyURI"/>
            </xsd:choice>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:simpleType name="schemaVersionNo">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="1.0"/>
        </xsd:restriction>
    </xsd:simpleType>
    <xsd:element name="MsgQMessage" type="IWS:MsgQMessageType"/>
</xsd:schema>

This XSD is included, above, to define the attachment:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
           targetNamespace="http://www.w3.org/2005/05/xmlmime" >
    <xs:attribute name="contentType">
        <xs:simpleType>
            <xs:restriction base="xs:string" >
                <xs:minLength value="3" />
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="expectedContentTypes" type="xs:string" />
    <xs:complexType name="base64Binary" >
        <xs:simpleContent>
            <xs:extension base="xs:base64Binary" >
                <xs:attribute ref="xmime:contentType" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
    <xs:complexType name="hexBinary" >
        <xs:simpleContent>
            <xs:extension base="xs:hexBinary" >
                <xs:attribute ref="xmime:contentType" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

I assign a block of XML to the MsgData field in the first XSD, in a BPEL, and convert the whole thing to a string and pass it through OpenMQ.  When the message is picked up at its destination, it looks OK.  It's all there and the JAXB object has created a getter for MsgData of type base64Binary that has a getValue() method that returns a byte[].  This byte[] is about the right length.

How do I convert that byte[] back to a String (so I get back a JAXB object for the original attached XML)?  

The bytes are encoded somehow - they are not just the bytes of a string - and I have been unable to determine how.

Thanks

 « Return to Thread: Passing base62binary through OpenMQ, what form does the data return in?