ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CREATING MIME MESSAGE

Post new topic  Reply to topic
 CREATING MIME MESSAGE « View previous topic :: View next topic » 
Author Message
jennifer.jose26
PostPosted: Thu Dec 02, 2010 6:28 am    Post subject: CREATING MIME MESSAGE Reply with quote

Newbie

Joined: 02 Dec 2010
Posts: 3

hey,
Does anybody have sample running code to create MIME messages ?

I have the requirement for reading a file that can be a pdf,mp3 etc from a folder , convert it into MIME message with multiple parts of say 10kb each and sending as a reply through HTTP Reply Node...

I managed to get some sample code but seems it doesnt work -

CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;

-- create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
--CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';

CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';

CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;

CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];

CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);

RETURN TRUE;


Can someone help ?
Back to top
View user's profile Send private message
veda
PostPosted: Thu Dec 02, 2010 6:49 am    Post subject: Re: CREATING MIME MESSAGE Reply with quote

Novice

Joined: 01 Dec 2010
Posts: 24

jennifer.jose26 wrote:
hey,
Does anybody have sample running code to create MIME messages ?

I have the requirement for reading a file that can be a pdf,mp3 etc from a folder , convert it into MIME message with multiple parts of say 10kb each and sending as a reply through HTTP Reply Node...

I managed to get some sample code but seems it doesnt work -

CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;

-- create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
--CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';

CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';

CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;

CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];

CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);

RETURN TRUE;


Can someone help ?


When you create a new MIME message, you have to make sure to set the ContentType property ! Did you try doing so?

SET OutputRoot.Properties.ContentType = 'text/plain';
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Dec 02, 2010 7:10 am    Post subject: Re: CREATING MIME MESSAGE Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

jennifer.jose26 wrote:
I managed to get some sample code but seems it doesnt work -


Doesn't work how? Abends? Produces output in the wrong format? Causes lightning to strike the tree outside your window?

Better information, better advice.

2 other points:

- Don't double post. If you think you've posted in the wrong place, ask for the post to be moved.

- Contain code in the proper code tags. It makes it much easier to read and follow
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Dec 02, 2010 7:39 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

PARSE() with DOMAIN('BLOB') is a no op, almost assuredly. If nothing else, it makes your code more confusing to read - but shouldn't actually be causing an issue.
Back to top
View user's profile Send private message
jennifer.jose26
PostPosted: Thu Dec 02, 2010 7:57 pm    Post subject: Reply with quote

Newbie

Joined: 02 Dec 2010
Posts: 3

Vitor,
Thanks for your advise. But there are better ways of making people aware of something than being rude. We all understand that you are an expert and thats why we are seeking your help. I really dont see any point in flaunting your knowledge by being rude to other.

Anyways, it would be great if you can help me understand the issue.

Problem -
1. the code code will break the file in two parts. But at ruintime i wanna give the flexibility of deciding how many parts the file has to be broken to based on some boundary condition, say "after writing 10KB records".

I have no idea on how to fit this logic into the existing code which is -

CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
-- CALL CopyMessageHeaders();
CALL CopyEntireMessage();

CREATE FIELD OutputRoot.MIME TYPE Name;
DECLARE M REFERENCE TO OutputRoot.MIME;

-- create the Content-Type child of MIME explicitly to ensure the correct order. If we set
-- the ContentType property instead, the field could appear as the last child of MIME.
--CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/related; boundary=myBoundary';

CREATE FIELD M."Content-Type" TYPE NameValue VALUE 'multipart/mixed; boundary="xxx"; charset="us-ascii"';
CREATE FIELD M."Content-ID" TYPE NameValue VALUE 'new MIME document';

CREATE LASTCHILD OF M TYPE Name NAME 'Parts';
-- some example data – generally this would be available already, perhaps as the result of
-- parsing another subtree.
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P1 REFERENCE TO M.Parts.Part;

CREATE FIELD P1."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P1."Content-Id" TYPE NameValue VALUE 'part one';
CREATE LASTCHILD OF P1 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE(newBlob);

CREATE LASTCHILD OF M.Parts TYPE Name NAME 'Part';
DECLARE P2 REFERENCE TO M.Parts.Part[2];

CREATE FIELD P2."Content-Type" TYPE NameValue VALUE 'text/plain';
CREATE FIELD P2."Content-Id" TYPE NameValue VALUE 'part two';
CREATE LASTCHILD OF P2 TYPE Name NAME 'Data';
CREATE LASTCHILD OF P2.Data DOMAIN('BLOB') PARSE(newBlob);

RETURN TRUE;
END;
Back to top
View user's profile Send private message
harish_td
PostPosted: Thu Dec 02, 2010 9:59 pm    Post subject: Reply with quote

Master

Joined: 13 Feb 2006
Posts: 236

I would ask these questions to myself.

Is my Input message indeed blob? (not because someone told me it is BLOB)

What is the value that gets saved after the below statement executed?
Code:
DECLARE newBlob BLOB InputRoot.BLOB.BLOB;


How am i splitting the incoming large data into smaller chunks?

If my input is BLOB, why should i re-parse that data as BLOB in the output?

What happens when i hard code the statement?
Code:
CREATE LASTCHILD OF P1.Data DOMAIN('BLOB') PARSE('HELLO WORLD',InputRoot.Properties.Encoding,InputRoot.Properties.CodedCharSetId);


My output message DOMAIN would always be BLOB; Why would i have to declare so many BLOB domain elements?
Back to top
View user's profile Send private message Yahoo Messenger
kimbert
PostPosted: Fri Dec 03, 2010 2:11 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
it would be great if you can help me understand the issue.
I suggest that you start by answering Vitor's questions, and doing what he suggested re: formatting your source code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » CREATING MIME MESSAGE
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.