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 » Setting Filename for FileOut Dynamically Using Value In XML

Post new topic  Reply to topic
 Setting Filename for FileOut Dynamically Using Value In XML « View previous topic :: View next topic » 
Author Message
bdaoust
PostPosted: Wed Nov 28, 2012 9:21 am    Post subject: Setting Filename for FileOut Dynamically Using Value In XML Reply with quote

Centurion

Joined: 23 Sep 2010
Posts: 130

I'm really new to WMB development, so bare with me.

I'm running WMB 7.0.0.3 in a Windows environment.

I have what I would think is an easy messageflow.

Input Node which I will be placing an XML file on. I've set the Message Domain on the input node to be XMLNSC.

Then in a compute node, I'd like to copy the XML message contents and send to a File Output Node, using a value in the XML as the filename.

I'd like the filename to be from the cmsCode value of the XML. It's not working and indicating that I'm trying to set the filename to null. I think the problem is that I'm not referencing the XML value correctly using:

SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.CaseImport.cmsCode;


I included the compute node code and part of the XML.

Compute Node code:

CREATE COMPUTE MODULE IncomingFromCMS_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyEntireMessage();
SET OutputLocalEnvironment.Destination.File.Directory = 'D:\MyDirectory';
SET OutputLocalEnvironment.Destination.File.Name = InputRoot.XMLNSC.CaseImport.cmsCode;
RETURN TRUE;
END;

CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;

CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;

Part of XML:

<?xml version="1.0" ?>
- <CaseImport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://blockforprivacy.com/CaseImport/">
<cmsCode xmlns="">ABC123</cmsCode>
<enrollmentName xmlns="">ABC international, LLC</enrollmentName>

Thanks in advance.

-Brian
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Nov 28, 2012 9:25 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

If you take a Trace node output of the structure of the message, you will see that CaseImport has a namespace on it and cmsCode does not, and so your ESQL must reference those.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Nov 28, 2012 10:00 am    Post subject: Re: Setting Filename for FileOut Dynamically Using Value In Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

bdaoust wrote:
I'm really new to WMB development, so bare with me.


Brian,

What's your game plan to learn WMB? Hopefully you can acquire the needed knowledge through resources like the InfoCentre or Training.

Have you tried to put together a message flow that specifies a filename ?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
bdaoust
PostPosted: Wed Nov 28, 2012 10:20 am    Post subject: Reply with quote

Centurion

Joined: 23 Sep 2010
Posts: 130

Hi there.

I actually took an IBM training class (through IBM) a few years ago, however it was pretty basic. Ex: here is WMB - here are a few nodes, etc. We built some simple messageflows, etc. But never did any ESQL stuff. So, I'm going through the online documentation and was hoping the forums would help me out as well.

Yes, I did try to put together a flow.

My current messageflow :

Input Node -----> going to ComputeNode ------> going to FileOutPutNode.

If I set the filename statically with :

SET OutputLocalEnvironment.Destination.File.Directory = 'D:\CMSEnrollmentKits';
SET OutputLocalEnvironment.Destination.File.Name = 'test.xml';

I get the desired results, but now I'm trying to set the filename dynamically based on the a value within my XML, but having issues.

I tried adding a Trace Node after the Input node. I set it as a File trace and specified the path. I get a file but it's only 1K and when I open that, it's blank.

Thanks
Brian
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Nov 28, 2012 10:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Did you put
Code:
${Root}
in the Pattern?

Again, you need to declare a namespace prefix and use
Code:
set OutputLocalEnvironment.Destination.File.Name=InputRoot.XMLNSC.ns1:CaseImport.cmsCode;
Back to top
View user's profile Send private message
bdaoust
PostPosted: Wed Nov 28, 2012 12:46 pm    Post subject: Reply with quote

Centurion

Joined: 23 Sep 2010
Posts: 130

Thanks mqjeff.

Is it possible to have broker create the directory based on a XML value and skip the creation of the folder if it already exists?

Thanks
Brian
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Nov 28, 2012 12:49 pm    Post subject: Reply with quote

Grand High Poobah

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

bdaoust wrote:
Is it possible to have broker create the directory based on a XML value and skip the creation of the folder if it already exists?


It's the default action of the FileOutput node to create the directory if it doesn't exist and not bother to create it if it doesn't.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Nov 28, 2012 1:13 pm    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Vitor wrote:
bdaoust wrote:
Is it possible to have broker create the directory based on a XML value and skip the creation of the folder if it already exists?


It's the default action of the FileOutput node to create the directory if it doesn't exist and not bother to create it if it doesn't.


Again, your asking basic questions that are found in the Infocentre and in the training classes.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Setting Filename for FileOut Dynamically Using Value In XML
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.