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 » namespace prefix in Java Compute node

Post new topic  Reply to topic
 namespace prefix in Java Compute node « View previous topic :: View next topic » 
Author Message
dipankar
PostPosted: Tue Mar 11, 2008 4:03 am    Post subject: namespace prefix in Java Compute node Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Hi All,
WBI MB 6.1, Broker fixpack 6101

I am trying to create namespace with prefix by java compute node like
Quote:
<getUserDetailsResp xmlns="http://commonMessageFormat/esb/common/esb" xmlns:ic="http://yell.com/esb/common/icommon" xmlns:ct="http://yell.com/esb/common/types" >
<eBusinessUser>
<ic:userId/>
<ic:contactBpId/>
<ic:userName/>
<ic:password/>
<ic:firstName/>
<ic:lastName/>
<ic:userAccountStatus/>
</eBusinessUser>
</getUserDetailsResp>


I can do this easily by Compute node by ESQL. But by Java code I am also able to do that but not in a good way.
This is the snapshot of my code -
Code:
MbElement outRoot = outMessage.getRootElement().createElementAsLastChild("XMLNSC");
MbElement getUserDetailsResp = outRoot.createElementAsFirstChild(MbXMLNSC.FOLDER,"getUserDetailsResp",null);
getUserDetailsResp.setNamespace("http://commonMessageFormat/esb/common/esb");
         
MbElement eBusinessUser = getUserDetailsResp.createElementAsFirstChild(MbXMLNSC.FOLDER, "eBusinessUser",null);
eBusinessUser.setNamespace("http://commonMessageFormat/esb/common/esb");
MbElement userId = eBusinessUser.createElementAsLastChild(MbXMLNSC.FIELD,"userId",ebuser.getUserId());
userId.setNamespace("http://yell.com/esb/common/icommon");         
MbElement contactBpId = eBusinessUser.createElementAsLastChild(MbXMLNSC.FIELD,"contactBpId",ebuser.getContactBpId());
contactBpId.setNamespace("http://commonMessageFormat/esb/common/esb");


I don't want to set namespace after creating every element. I would to like to do the same just like esql - first declare namespace with prefix & then use prefix:element_name for creating output body. Here all child element is having the same namespace. However, I am setting namespace for every child element explicitly. I am not able to use prefix.

Please let me know if there is any way to do that. I have very little knowledge in Java.
_________________
Regards
Back to top
View user's profile Send private message
hakanhu
PostPosted: Wed Mar 12, 2008 1:37 am    Post subject: Reply with quote

Newbie

Joined: 30 Jan 2007
Posts: 7

You must set namespace every time.
To get less complex Java code create methods in a generic Java class to handle it.


Could look like this
public MbElement createLastChild(MbElement parent, String name, Object value, String namespace) {
MbElement element = parent.createElementAsLastChild(MbXMLNSC.FIELD, name, value);
element.setNamespace(namespace);
return element;
}
Back to top
View user's profile Send private message
dipankar
PostPosted: Wed Mar 12, 2008 1:48 am    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Hi hakanhu,
Thanks a lot. I am doing the same.
_________________
Regards
Back to top
View user's profile Send private message
issac
PostPosted: Sat Jun 04, 2011 7:13 pm    Post subject: Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Hello,

How did you manage to add the prefix "ic:" please?
_________________
Bazinga!
Back to top
View user's profile Send private message
mqjeff
PostPosted: Sun Jun 05, 2011 7:18 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

issac wrote:
Hello,

How did you manage to add the prefix "ic:" please?

You create an element in the logical message tree that the XMLNSC parser understands to be describing an XML namespace prefix, and then you set the value of this element in the logical message tree to the string "ic".
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 » namespace prefix in 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.