|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to convert char to BLOB? |
« View previous topic :: View next topic » |
Author |
Message
|
Shek |
Posted: Mon Oct 18, 2004 12:58 pm Post subject: How to convert char to BLOB? |
|
|
Newbie
Joined: 18 Oct 2004 Posts: 6
|
I have a BLOB message that was converted to MRM. It has several integer fields, followed by a string field, which displays in the debugger as CHAR. I just need the contents of this string field sent to a custom node as a BLOB.
I've tried setting a blob to ASBITSTREAM(charField), but this throws an exception. I've read the documentation for ASBITSTREAM, but can't make much sense of the various settings.
Does anyone know how to take the contents of a char and convert it to a blob? |
|
Back to top |
|
 |
Nizam |
Posted: Mon Oct 18, 2004 1:26 pm Post subject: |
|
|
Disciple
Joined: 10 Feb 2004 Posts: 160
|
|
Back to top |
|
 |
kirani |
Posted: Mon Oct 18, 2004 1:46 pm Post subject: |
|
|
Jedi Knight
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
|
Don't forget to use CCSID option. For example,
Code: |
SET OutputRoot."BLOB"."BLOB" = CAST (InputRoot.MRM.CHARFIELD AS BLOB CCSID InputRoot.Properties.CodedCharSetId);
|
_________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
|
|
Back to top |
|
 |
Shek |
Posted: Tue Oct 19, 2004 9:03 am Post subject: |
|
|
Newbie
Joined: 18 Oct 2004 Posts: 6
|
Thanks. Switching to the CAST operation gets me closer, but not quite there yet. The value in the string field is actually the contents of a .pdf file, which has some binary data. I'm assuming that the "CCSID InputRoot.Properties.CodedCharSetId" clause is performing some type of character conversion, because the original length is 12441, and the resulting blob, which is passed to a base 64 encoder to be used in an xml messgage, and then decoded by my application, is 16289. The acrobat reader declares it to be corrupt and unreadable.
Do you know the correct settings to prevent character conversion of the binary values in the string? |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Oct 19, 2004 9:28 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you want to treat this data as BLOB data, why are you modelling it as string data in the first place?
If you DO NOT use the CCSID parameter, then you will not get any character conversion, merely a type conversion. This is usually NOT what people want to do. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Shek |
Posted: Tue Oct 19, 2004 10:43 am Post subject: |
|
|
Newbie
Joined: 18 Oct 2004 Posts: 6
|
After some debugging, it appears that the character conversion is happening before this cast operation.
Does anyone know what aspect of the code below is causing the conversion, and how to prevent it?
Code: |
DECLARE InputBlobMsg BLOB;
DECLARE options INTEGER BITOR(RootBitStream, ValidateContent,ValidateValue,ValidateComplete);
SET InputBlobMsg = BITSTREAM(InputRoot."BLOB"."BLOB");
-- Construct the Output Message
CREATE LASTCHILD OF OutputRoot DOMAIN 'MRM';
-- Declare the Output reference
DECLARE creationPtr REFERENCE TO OutputRoot.MRM;
-- Validate the input the Message against the mrm Schema provided.
CREATE FIRSTCHILD OF creationPtr PARSE(InputBlobMsg OPTIONS options ENCODING InputRoot.MQMD.Encoding CCSID InputRoot.MQMD.CodedCharSetId SET 'DocNot' TYPE 'XtreamRsp' FORMAT 'CWF1');
-- Note: In debug , the CCSID is 437, ENCODING is 437.
SET OutputRoot."BLOB"."BLOB" = CAST (creationPtr.output AS BLOB CCSID InputRoot.Properties.CodedCharSetId); |
Here is the schema for the parse operation:
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="XtreamRsp">
<xsd:sequence>
<xsd:element name="Intro" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<cwfInclRep messageSetDefaultRep="CWF1" repeatCount="1">
<cwfSimpleRep
encodingNull="NullLogicalValue"
encodingNullValue="" lengthUnits="Bytes"
mrLengthEncoding="fixedLength"
paddingCharacter="NUL"
stringJustification="leftJustify"
typeName="MRCWFStringRep" width="27"/>
</cwfInclRep>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element default="24" name="headerLength" type="xsd:int"/>
<xsd:element default="100" name="version" type="xsd:int"/>
<xsd:element default="4" name="PDL" type="xsd:int"/>
<xsd:element default="0" name="outputLength" type="xsd:int"/>
<xsd:element default="0" name="messageLength" type="xsd:int"/>
<xsd:element default="0" name="userDataLength" type="xsd:int"/>
<xsd:element minOccurs="1" name="output" type="xsd:string"/>
<xsd:element minOccurs="0" name="message" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<cwfInclRep
lengthReference="/XtreamRsp;XSDComplexTypeDefinition/XSDParticle/XSDModelGroup/XSDParticle=5/messageLength;XSDElementDeclaration/" messageSetDefaultRep="CWF1">
<cwfSimpleRep
encodingNull="NullLogicalValue"
encodingNullValue="" lengthUnits="Bytes"
mrLengthEncoding="fixedLength"
paddingCharacter="NUL"
stringJustification="leftJustify" typeName="MRCWFStringRep"/>
</cwfInclRep>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element minOccurs="0" name="userData" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<cwfInclRep
lengthReference="/XtreamRsp;XSDComplexTypeDefinition/XSDParticle/XSDModelGroup/XSDParticle=6/userDataLength;XSDElementDeclaration/" messageSetDefaultRep="CWF1">
<cwfSimpleRep
encodingNull="NullLogicalValue"
encodingNullValue="" lengthUnits="Bytes"
mrLengthEncoding="fixedLength"
paddingCharacter="NUL"
stringJustification="leftJustify" typeName="MRCWFStringRep"/>
</cwfInclRep>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="XtreamRsp" type="XtreamRsp">
<xsd:annotation>
<xsd:appinfo source="WMQI_APPINFO">
<MRMessage messageDefinition="/XtreamRsp;XSDElementDeclaration/"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:schema> |
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|