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 » Problem with namespace prefix defaulting to NS1

Post new topic  Reply to topic
 Problem with namespace prefix defaulting to NS1 « View previous topic :: View next topic » 
Author Message
tony_f
PostPosted: Tue Feb 05, 2013 3:28 am    Post subject: Problem with namespace prefix defaulting to NS1 Reply with quote

Novice

Joined: 30 Sep 2011
Posts: 19

Hi

I have two ESQL's that are pretty much identical. They both write out to the same message set that is defined to use namespaces. The namespace declaration is defined to use a prefix of ph.

This ESQL produces a message with the prefixes of ph generated correctly
Code:


DECLARE ph NAMESPACE 'http://parker.com/';

CREATE COMPUTE MODULE JDEStockAvailReqToCommon_Compute
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
       CALL CopyMessageHeaders();
      -- CALL CopyEntireMessage();
      
         
         -- declare REFERENCEs to the trees to pass to the transform procedure
      DECLARE outRef   REFERENCE TO OutputRoot;
      DECLARE pHeadRef   REFERENCE TO OutputRoot.XMLNSC.ph:ParkerMsg.ph:Header.ph:ParkerHeader;
      DECLARE stockItemRef REFERENCE TO OutputRoot.XMLNSC.ph:ParkerMsg.ph:Body.ph:t_StockAvailReq;      
            

      DECLARE jdeappRef REFERENCE TO InputRoot.XMLNSC.JDERealTimeStockEnquiryReq.ApplicationHeader;
      DECLARE jdedtl   REFERENCE TO InputRoot.XMLNSC.JDERealTimeStockEnquiryReq.MessageDetail;

      
      
      --  Set up fields and references
      DECLARE datePattern CHARACTER 'yyyy-MM-dd';
      DECLARE i INTEGER;
      DECLARE j INTEGER;    
      
      CREATE LASTCHILD OF outRef DOMAIN 'XMLNSC';
      CREATE FIELD OutputRoot.XMLNSC.ph:ParkerMsg.ph:Header.ph:ParkerHeader AS pHeadRef;
      CREATE FIELD OutputRoot.XMLNSC.ph:ParkerMsg.ph:Body.ph:t_StockAvailReq AS stockItemRef;

      -- XML Declaration - Create the XML Declaration.
      ------------------------------------------------      
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version = '1.0';
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding = 'UTF-8';
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)StandAlone = 'yes';
       
      --  Set up Message Properties
      SET outRef.Properties.MessageSet = 'CommonStockEnquiryMessage';
      SET outRef.MQMD.Format = MQFMT_STRING;      
      
      -- Build Parker Header Fields   
      SET pHeadRef.ph:DivisionID = jdeappRef.DivisionID;
      SET pHeadRef.ph:MessageType = '';   
      SET pHeadRef.ph:SourceSystem = COALESCE(TRIM(jdeappRef.SourceSystem),'JDE_EU');      
      SET pHeadRef.ph:TargetSystem = '';
      SET pHeadRef.ph:UnitWorkType = '';
      SET pHeadRef.ph:UnitWorkNumber = '';
      SET pHeadRef.ph:ServiceName = COALESCE(TRIM(jdeappRef.ServiceName),'JDESTOCKENQUIRY');      
      SET pHeadRef.ph:Action = COALESCE(TRIM(jdeappRef.Action),'');               
      SET pHeadRef.ph:RequestorID = COALESCE(TRIM(jdeappRef.RequestorID),'');
      SET pHeadRef.ph:AuthID = COALESCE(TRIM(jdeappRef.AuthID),'');
      SET pHeadRef.ph:OwnerID = COALESCE(TRIM(jdeappRef.OwnerID),'');
      SET pHeadRef.ph:Date = CURRENT_DATE;
      SET pHeadRef.ph:Time = CAST(CURRENT_TIME AS CHAR FORMAT 'HH:mm:ssZZZ');
      
      --Build message body
      SET stockItemRef.ph:ItemNumber = jdedtl.ItemNumber;
      SET stockItemRef.ph:QtyAvailable = 0;
      SET stockItemRef.ph:QtyOnHand = 0;
      SET stockItemRef.ph:Status = '';
      SET stockItemRef.ph:UnitOfMeasure = '  ';
      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;



However this ESQL produces a message with a namespace prefix of NS1

Code:

   
DECLARE ph NAMESPACE 'http://parker.com/';

CREATE COMPUTE MODULE LegrisStockAvailRspToCommon
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
       CALL CopyMessageHeaders();
      -- CALL CopyEntireMessage();
      
            
      -- declare REFERENCEs to the trees to pass to the transform procedure
      DECLARE outRef   REFERENCE TO OutputRoot;
      DECLARE pHeadRef   REFERENCE TO OutputRoot.XMLNSC.ph:ParkerMsg.ph:Header.ph:ParkerHeader;
      DECLARE stockItemRef REFERENCE TO OutputRoot.XMLNSC.ph:ParkerMsg.ph:Body.ph:t_StockAvailReq;
            

      DECLARE legrisDtl REFERENCE TO InputRoot.XMLNSC.StockAvailabilityResponse;
      DECLARE appHeader REFERENCE TO InputRoot.XMLNSC.StockAvailabilityResponse.AppHeader;
      

      
      
      --  Set up fields and references
      DECLARE datePattern CHARACTER 'yyyy-MM-dd';
      DECLARE i INTEGER;
      DECLARE j INTEGER;    
      
      CREATE LASTCHILD OF outRef DOMAIN 'XMLNSC';
      CREATE FIELD OutputRoot.XMLNSC.ph:ParkerMsg.ph:Header.ph:ParkerHeader AS pHeadRef;
      CREATE FIELD OutputRoot.XMLNSC.ph:ParkerMsg.ph:Body.ph:t_StockAvailReq AS stockItemRef;
      
      -- XML Declaration - Create the XML Declaration.
      ------------------------------------------------      
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version = '1.0';
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding = 'UTF-8';
      SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)StandAlone = 'yes';
       
      --  Set up Message Properties
      SET outRef.Properties.MessageSet = 'CommonStockEnquiryMessage';
      SET outRef.MQMD.Format = MQFMT_STRING;      
      
            
      -- Build Parker Header Fields   
      SET pHeadRef.ph:DivisionID = appHeader.DivisionID;
      SET pHeadRef.ph:MessageType = '*RESPONSE';   
      SET pHeadRef.ph:SourceSystem = COALESCE(TRIM(appHeader.SourceSystem),'JDE_EU');      
      SET pHeadRef.ph:TargetSystem = '';
      SET pHeadRef.ph:UnitWorkType = '';
      SET pHeadRef.ph:UnitWorkNumber = '';
      SET pHeadRef.ph:ServiceName = appHeader.ServiceName;      
      SET pHeadRef.ph:Action =  '';               
      SET pHeadRef.ph:RequestorID = '';
      SET pHeadRef.ph:AuthID = '';
      SET pHeadRef.ph:OwnerID =  '';
      SET pHeadRef.ph:Date = CURRENT_DATE;
      SET pHeadRef.ph:Time = CAST(CURRENT_TIME AS CHAR FORMAT 'HH:mm:ssZZZ');
      
            
      --Build message body
      SET stockItemRef.ph:ItemNumber = legrisDtl.ItemNumber;
      SET stockItemRef.ph:QtyAvailable = legrisDtl.QtyAvailable;
      SET stockItemRef.ph:QtyOnHand = legrisDtl.QtyOnHand;
      SET stockItemRef.ph:Status = legrisDtl.Status;
      SET stockItemRef.ph:UnitOfMeasure = legrisDtl.UnitOfMeasure;
      
      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;


I can't see why the outputs should be different between these two sets of code. Can anyone help to point out what the possible cause of this could be.

Thanks
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Feb 05, 2013 3:34 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

I suggest that you read this: http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp

XMLNSC does not use the list of preferred namespace prefixes in the message set. In fact, it does not use any information from the XML physical format in a message set - because physical formats are for use by the MRM parser only.

I cannot easily compare that much source code, but the short answer is that you need to build the correct message tree - the XML document that is written by XMLNSC depends only on the contents of the message tree. If you can't see where the problem is, insert a Trace node immediately before the output node and compare the working/non-working traces.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Feb 05, 2013 5:04 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I don't see anywhere in the code where it is creating an XMLNSC.NamespaceDecl.
Back to top
View user's profile Send private message
tony_f
PostPosted: Tue Feb 05, 2013 6:12 am    Post subject: Reply with quote

Novice

Joined: 30 Sep 2011
Posts: 19

mqjeff wrote:
I don't see anywhere in the code where it is creating an XMLNSC.NamespaceDecl.


I didn't think I needed to specify XMLNSC.NamespaceDecl as in the first ESQL it's providing the correct namespace prefix.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Feb 05, 2013 6:26 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

The namespace prefixes in your ESQL SET statements are specifying the namespace of the target element in OutputRoot.XMLNSC. That is a necessary step, but it does not mean that your output XML will contain the same prefixes as you are using in your ESQL.

ESQL builds or modifies message trees. Sometimes message trees have namespaces on some or all of their elements.
XMLNSC builds message trees from XML documents, and writes XML documents from message trees. It handles namespace prefixes exactly as described in the info center topic that I quoted earlier.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Feb 05, 2013 6:28 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

To put what kimbert said in a different way... the ESQL "DECLARE .. NAMESPACE" statement makes absolutely no modifications to the message tree.

It only provides context for the ESQL code when it executes, so that the paths used in ESQL can be resolved properly.

And further, there should be absolutely nothing "wrong" or a "problem" with an XML namespace prefix being "ns1" or "ph" or "bobsyouruncle".

Absolutely no application anywhere should have coded any dependence on the specific characters defined to represent a specific namespace.
Back to top
View user's profile Send private message
tony_f
PostPosted: Tue Feb 05, 2013 7:58 am    Post subject: Reply with quote

Novice

Joined: 30 Sep 2011
Posts: 19

Thanks for all the replies. I've tried to replicate the example on the link that Kimbert sent me and I can't seem to get it to work. If the first child of XMLNSC is called ParkerMsg, I was expecting this to work

Code:

DECLARE ph1 NAMESPACE 'http://parker.com/';
   
CREATE COMPUTE MODULE LegrisStockAvailRspToCommon
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
       CALL CopyMessageHeaders();
      -- CALL CopyEntireMessage();
      
       SET OutputRoot.XMLNSC.ph1:ParkerMessage.(XMLNSC.NamespaceDecl)xmlns:ph = ph1;



but if failed when I ran it with this error :

BIP5016E: The element with name 'ParkerMsg' and field type 'folderType' is not valid as the child of Root.XML or Root.XMLNSC.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Feb 05, 2013 8:08 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

The ESQL that you quoted could not possibly give rise to that error message - the element names are different. This is a very well-tested area of the product, so this is probably a mistake in your flow.
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 » Problem with namespace prefix defaulting to NS1
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.