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 IndexWebSphere Message Broker SupportNamspac issue:Copy XML into environment variable and MQ

Post new topicReply to topic
Namspac issue:Copy XML into environment variable and MQ View previous topic :: View next topic
Author Message
Muhammad Haider
PostPosted: Mon Dec 26, 2016 3:35 am Post subject: Namspac issue:Copy XML into environment variable and MQ Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

Hi,

I am implementing a webservice retry logic. I copy the soap body in environment variable and then make a mq request to store the request in MQ.

Code:
Code:
SET OutputRoot.XMLNSC.Msg.body = Environment.SOAP.Body;
SET OutputRoot.XMLNSC.Msg.RetryCounter = Environment.RetryCounter;


On first time here is the xml:

Code:
<Msg>
  <body>
      <NS1:po xmlns:NS1="http://www.example.org/NewXMLSchema">
         <NS1:id>b</NS1:id>
      </NS1:po>
   </body>
   <RetryCounter>0</RetryCounter>
</Msg>

But the next time in loop, when I put the message in Mq using same logic, an extra namespace element tag is generated which causes parser issue. You can examine the new message and the tag generated below:

New message:
Code:
<Msg>
   <body>
      <NS1:po xmlns:NS1="http://www.example.org/NewXMLSchema">   
      <xmlns:NS1>http://www.example.org/NewXMLSchema</xmlns:NS1>
         <NS1:id>A</NS1:id>
      </NS1:po>
   </body>
   <RetryCounter>1</RetryCounter>
</Msg>


Extra tag:
Code:
<xmlns:NS1>http://www.example.org/NewXMLSchema</xmlns:NS1>


Parsing issue:
An XML parsing error has occurred while parsing the XML document. The namespace prefix "xmlns" was not declared.

How can this issue be eliminated ?

Thanks.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Dec 26, 2016 12:48 pm Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20022
Location: LI,NY

Remember that by default the environment does not have a parser attached...
So may be you should attach a parser to the environment before "parking" anything there.
As for the extra namespace declaration: most probably due to a programing error on your part...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
timber
PostPosted: Wed Dec 28, 2016 1:29 pm Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1000

Use the CREATE statement with a DOMAIN clause when creating the destination in the LocalEnvironment tree. Specify XMLNSC as the domain.

The 'extra' namespace tag is simply the xmlns attribute (more correctly, the namespace declaration) which has been turned into a tag because its parser-specific field type has been discarded. This will stop happening when you fix the domain issue.
Back to top
View user's profile Send private message
Muhammad Haider
PostPosted: Thu Dec 29, 2016 7:28 pm Post subject: Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

Thanks timber and fjb_saper. You pointed to the correct issue that while putting/getting from environment we should use statements like:

getting from environment:
CREATE LASTCHILD OF OutputRoot.XMLNSC.Msg DOMAIN('XMLNSC');
SET OutputRoot.XMLNSC.Msg.XMLNSC = Environment.Variables.XMLNSC;

saving in environment:
CREATE LASTCHILD OF Environment.Variables DOMAIN('XMLNSC');
SET Environment.Variables.XMLNSC.*[] = InputRoot.XMLNSC.Msg.XMLNSC.*[];

i found following link useful as well:
http://www.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.scenarios.doc/gop_03/topics/bj60033_.htm

further if we are using a mqget/mq input node and if we are just using xmlnsc domain with no explicit message model mentioned even then this issue happens and a tag is created for xmlns attribute. one way to avoid this issue is to add required location/tag that contains your xml with namespaces like e.g i added full soap envelope i.e '//tns:Envelope' in 'Opaque elements' on 'Parser Options' tab of mq node.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Dec 29, 2016 10:19 pm Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20022
Location: LI,NY

Muhammad Haider wrote:

saving in environment:
Code:
CREATE LASTCHILD OF Environment.Variables DOMAIN('XMLNSC');
SET Environment.Variables.XMLNSC.*[] = InputRoot.XMLNSC.Msg.XMLNSC.*[];


I am not sure this will really do what you want it to.
I'd have thought you'd code it this way:
Code:
CREATE LASTCHILD OF Environment.Variables DOMAIN('XMLNSC') Name 'XMLNSC';
SET Environment.Variables.XMLNSC.*[] = InputRoot.XMLNSC.Msg.XMLNSC.*[];

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Muhammad Haider
PostPosted: Fri Dec 30, 2016 5:20 am Post subject: Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

Thanks fjb_saper for the correction. I have updated my code and tested, its also working fine.

Plus, as updated earlier, adding xml structures as Opaque Elements for mq get/mq input nodes is proving useful for me, as otherwise i get the xmlns exception: 'The namespace prefix "xmlns" was not declared.'
Back to top
View user's profile Send private message
timber
PostPosted: Fri Dec 30, 2016 3:07 pm Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1000

Actually, this:
Code:
CREATE LASTCHILD OF Environment.Variables DOMAIN('XMLNSC');
is exactly equivalent to this:
Code:
CREATE LASTCHILD OF Environment.Variables DOMAIN('XMLNSC') Name 'XMLNSC';
...although it does no harm to include the NAME clause for clarity.

While we're discussing the details of ESQL, this:
Code:
SET Environment.Variables.XMLNSC.*[] = InputRoot.XMLNSC.Msg.XMLNSC.*[];
is almost exactly equivalent to this:
Code:
SET Environment.Variables.XMLNSC = InputRoot.XMLNSC.Msg.XMLNSC;

The only difference is that the second one will copy the value of InputRoot.XMLNSC.Msg.XMLNSC as well as the child elements. But I suspect that it will not have a value because it is representing the root tag of an XML document.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportNamspac issue:Copy XML into environment variable and MQ
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.