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 » Creatting default namespace using Java Compute Node

Post new topic  Reply to topic Goto page 1, 2, 3  Next
 Creatting default namespace using Java Compute Node « View previous topic :: View next topic » 
Author Message
satya2481
PostPosted: Tue Dec 30, 2008 9:48 pm    Post subject: Creatting default namespace using Java Compute Node Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Hi,
I am developing an interface in WMB Toolkit V6.1 Fixpack 3. The mapping is done using the Java comute node.
The incoming message is MRM (TDS) format and outgoing message is MRM (XML) format. I need to create a default namespace using the Java compute node.
Has anyone used the JCN node and java coding to create the default namespace.

Thank you in advance
Satya
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Wed Dec 31, 2008 2:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

The MbElement class offers getNamespace() and setNamespace() methods.

But it's the MRM parser, not the Java API, that normally handles the namespace declarations, using the given message set definitions.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Dec 31, 2008 3:17 am    Post subject: Reply with quote

Grand High Poobah

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

There is no default namespace in the broker as such (6.0 check the 6.1 doc for changes but I don't remember seeing any) .
You have to declare the namespace and set it for every element / attribute in your MRM tree in your java compute node.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Dec 31, 2008 7:06 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You should not need to adjust or work with namespaces directly in your code when using MRM-XML.

You should be able to add the namespace in the correct places in the MRM model XML physical format.
Back to top
View user's profile Send private message
satya2481
PostPosted: Wed Dec 31, 2008 8:32 am    Post subject: Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Quote:
The MbElement class offers getNamespace() and setNamespace() methods.


If I need to use these methods I will have to pass the namespace String to these methods. In that case the fields will be prefixed with this namespace. My requirement is that all the fields which are not having the namespace prefix should be considered as under the default namespace.


Quote:
There is no default namespace in the broker as such (6.0 check the 6.1 doc for changes but I don't remember seeing any) .
You have to declare the namespace and set it for every element / attribute in your MRM tree in your java compute node.


If this is the case then how to handle the default namespaces. Is it mandatory to create the namespace prefix for all the elements? even when the fields are under default namespace?

Quote:
You should not need to adjust or work with namespaces directly in your code when using MRM-XML.


Yes you are right. I have tried to adjust the default namespace in the message set level. But I dont know is there any unique prefix name with which broker understands that the namespace is a default namespace.

The main requirement from our client is that they dont want broker to generate namespace prefix for some of the elements which are under default namepsaces. For example

The broker generating output message as

Code:

<?xml version="1.0"?>
<test:MyPO xmlns:test="http://www.test.com/test" xmlns:oa="http://www.openapplications.org/oagis/9">
 <oa:ApplicationArea>
  <oa:CreationDateTime>2008-12-31</oa:CreationDateTime>
 </oa:ApplicationArea>
 <test:DataArea>
 </test:DataArea>
 </test:MyPO>
 


But the client requirement is that output should look like below

Code:
<?xml version="1.0"?>
<MyPO xmlns="http://www.test.com/test" xmlns:oa="http://www.openapplications.org/oagis/9">
 <oa:ApplicationArea>
  <oa:CreationDateTime>2008-12-31</oa:CreationDateTime>
 </oa:ApplicationArea>
 <DataArea>
 </DataArea>
 </MyPO>


That means all the elements which are not having namespace prefix should be considered as of default namespace elements.

Thank you all for your reply...
Satya
_________________
IBM Certified Solution Developer WebSphere Message Broker V6.0
IBM Certified System Administrator WebSphere MQ V6.0


Last edited by satya2481 on Mon Jan 19, 2009 2:02 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Dec 31, 2008 9:38 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

The client requirement doesn't make sense. Those are equivalent XML documents and should not affect processing in any way.

That said, you do have control over what the namespace prefix is, again in the XML physical layer. It may work if you set it to blank.

But you may not be able to achieve this useless requirement using MRM-XML, and should almost certainly be considering using XMLNSC anyway.
Back to top
View user's profile Send private message
satya2481
PostPosted: Thu Jan 01, 2009 8:28 am    Post subject: Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Yes, I can understand that the message with default namespace or with the namespace prefix are same. I am even able to validate the broker generated message agaisnt the schema file in the XMLSpy tool.

I could have used XMLNSC domain for this but in this domain attributes are not getting created.

Do you mean using MRM-XML it is not possible to create the default namespace? Cant we give some kind of key values with which broker understands that it is a default namespace. I am trying to search on this point....
I need to suppress some unused namespaces also from the output message...

Thank you for your reply...
Satya
_________________
IBM Certified Solution Developer WebSphere Message Broker V6.0
IBM Certified System Administrator WebSphere MQ V6.0
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Jan 01, 2009 12:39 pm    Post subject: Reply with quote

Grand High Poobah

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

Quote:
I could have used XMLNSC domain for this but in this domain attributes are not getting created.

?? How are you trying to create an attribute in XMLNSC ??
You do know that the type is XMLNSC.Attribute and not XML.Attribute for XMLNSC right?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Thu Jan 01, 2009 3:59 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Do you mean using MRM-XML it is not possible to create the default namespace?
That is the situation. This is one of many reasons why XMLNSC is a better choice.
Quote:
I could have used XMLNSC domain for this but in this domain attributes are not getting created.
When you are using XMLNSC, you need to set the field type of each attribute to XMLNSC.Attribute. This is not necessary when using MRM XML, so maybe you did not realize that it was needed.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Jan 02, 2009 1:27 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

satya2481 wrote:
Do you mean using MRM-XML it is not possible to create the default namespace? Can't we give some kind of key values with which broker understands that it is a default namespace. I am trying to search on this point....
I need to suppress some unused namespaces also from the output message...

As mqjeff suggested, you might be able to accomplish this by editing the "Namespace settings" in the XML wire format. One way to verify that is to try it and see what happens.

Whether this is the best approach is another matter. As several people have suggested, XMLNSC is probably a better choice, for many reasons. As of WMB 6.1, XMLNSC offers schema validation, if the referenced message set's "Message Domain" property is set appropriately, and deployed.

satya2481 wrote:
I could have used XMLNSC domain for this but in this domain attributes are not getting created.

For creating XMLNSC attributes, you need to specify the field type, in ESQL (XMLNSC.Attribute), or in java (MbXMLNSC.ATTRIBUTE).

For creating XMLNSC namespace declarations, you need to specify the field type, in ESQL (XMLNSC.NamespaceDecl), or in java (MbXMLNSC.NAMESPACE_DECLARATION).
Back to top
View user's profile Send private message
satya2481
PostPosted: Sun Jan 04, 2009 7:07 am    Post subject: Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Thanks for all the replies...

Now I am planning to use XMLNS domain... I am facing an issue with creating the default namespace... below is my code in JCN node

Code:
MbElement xmlDecl = outRoot.createElementAsFirstChild(MbXMLNS.XML_DECL); 
      xmlDecl.setName("XmlDeclaration"); 
      xmlDecl.createElementAsFirstChild(MbXMLNS.VERSION, "version", "1.0");
      xmlDecl.createElementAsFirstChild(MbXMLNS.ENCODING, "encoding", "utf-8");
      xmlDecl.createElementAsFirstChild(MbXMLNS.STANDALONE, "standalone", "yes");
      
      MbElement spo = outRoot.createElementAsLastChild(MbXMLNS.ELEMENT, "TestPO", null);
      
      spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "oa", "http://www.openapplications.org/oagis/9");
      spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "", "http://www.test.com/testPO");


this is generating the output like this

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<TestPO oa="http://www.openapplications.org/oagis/9" ="http://www.test.com/testPO" versionID="normalizedString" releaseID="1.0">


I need to produce an output which should look like this

Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<TestPO xmlns:oa="http://www.openapplications.org/oagis/9" xmlns="http://www.test.com/testPO" versionID="normalizedString" releaseID="1.0">


I have tried searching in the MbXMLNS and MbXML methods in the IBM Site. but didnt find the solution for this...

Any help on this is needed...

Thank You
Satya
_________________
IBM Certified Solution Developer WebSphere Message Broker V6.0
IBM Certified System Administrator WebSphere MQ V6.0


Last edited by satya2481 on Mon Jan 19, 2009 10:11 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
smdavies99
PostPosted: Sun Jan 04, 2009 10:05 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

I take it you have tried
[code]
spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "xmlns:oa", "http://www.openapplications.org/oagis/9");
spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "xmlns", "http://www.volvo.com/3P/Purchasing/2008/10");


[/code]
I'm not a java expert (and it seems that this is simpler to do in ESQL or with a message set) so all the usual disclaimers apply.

Stephen D
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Sun Jan 04, 2009 6:25 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

XMLNS doesn't offer any schema validation, if that's important to you.

You might try something like:
Code:
MbElement oa = spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL,
    "oa", "http://www.openapplications.org/oagis/9");

oa.setNamespace("http://www.volvo.com/3P/Purchasing/2008/10");

spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL,
    "xmlns", "http://www.volvo.com/3P/Purchasing/2008/10");
Back to top
View user's profile Send private message
satya2481
PostPosted: Sun Jan 04, 2009 9:27 pm    Post subject: Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Hi,

I have tried using the below code

Code:
spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "xmlns:oa", "http://www.openapplications.org/oagis/9");
spo.createElementAsLastChild(MbXMLNS.NAMESPACE_DECL, "xmlns", "http://www.volvo.com/3P/Purchasing/2008/10");


I am not getting the output message only. When I checked the reason for the failure by adding a Reset Content Descriptor node in the flow below exception is reported.

Code:
Number:INTEGER:5014
                     Text:CHARACTER:Element must have a namespace specified if there is a default namespace in scope
                     Insert
                           Type:INTEGER:5
                           Text:CHARACTER:SyncPurchaseOrder


I have also tried using the code mentioned by rekarm01. for this a new namepace "NS1" is getting created automatically.

I would like to know how to create the default namespace in XMLNS domain using Java compute node....

Thanks again for your reply.
Back to top
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Jan 05, 2009 4:09 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Hi satya2481,

Quote:
Now I am planning to use XMLNS domain
You are using v6.1, and you are generating an output XML message, so I am surprised that you have chosen XMLNS instead of XMLNSC. Did you think that XMLNS would be easier? ( it will not ). Was there another reason?

Quote:
I checked the reason for the failure by adding a Reset Content Descriptor node
Why not simply take a User Trace? Just as easy, and provides more info. Or simply look at the system error log or Windows Event Viewer, depending on your development platform.

Quote:
exception is reported: Element must have a namespace specified if there is a default namespace in scope
This has been explained several times on this forum, and I seem to remember that the error message is very clear as well. All WMB parsers require you to set the namespace on every element in the message tree - child elements do not 'inherit' the default namespace ( or any other namespace ) from their parents.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2, 3  Next Page 1 of 3

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Creatting default namespace using Java Compute Node
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.