|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Creating namespaces in Java compute node |
« View previous topic :: View next topic » |
Author |
Message
|
NAIDU |
Posted: Wed May 10, 2017 11:49 am Post subject: Creating namespaces in Java compute node |
|
|
Novice
Joined: 12 Jan 2016 Posts: 17
|
Hi All,
I struggle to create namespaces . I wanted to construct message like
<out7:getCustomerSubscriptionInfoResponse xmlns:out7="http://wsdl.ussco.com/CustomerSubscription/CustomerSubscriptionInterface" xmlns:out13="http://wsdl.ussco.com/CustomerSubscription/ShowCustomerSubscription">
<out13:ShowCustomerSubscription>
<SubscriptionDetail>
<TrdParnterId>hello</TrdParnterId>
</SubscriptionDetail>
</out13:ShowCustomerSubscription>
</out7:getCustomerSubscriptionInfoResponse>
Now i was trying with code :
MbElement XMLNSC=outputroot.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement getCustomerSubscriptionInfoResponse=XMLNSC.createElementAsLastChild(MbElement.TYPE_NAME,"getCustomerSubscriptionInfoResponse",null);
getCustomerSubscriptionInfoResponse.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "xmlns:out7", "http://wsdl.ussco.com/CustomerSubscription/CustomerSubscriptionInterface");
MbElement ShowCustomerSubscription = getCustomerSubscriptionInfoResponse.createElementAsLastChild(MbElement.TYPE_NAME,"ShowCustomerSubscription",null);
ShowCustomerSubscription.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "out13", "http://wsdl.ussco.com/CustomerSubscription/ShowCustomerSubscription");
Can anyone help me out |
|
Back to top |
|
 |
timber |
Posted: Wed May 10, 2017 12:03 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Yes, the Java API is not particularly user-friendly when it comes to namespaces. The trick is to set the namespace on each and every node in the message tree ( your code is not doing that; it is only creating namespace declarations).
I think this thread should be helpful:
http://www.mqseries.net/phpBB/viewtopic.php?p=234727&sid=6a0ccb34e9fbbd6e28beaa5b4958a7e1
See my post under the name kimbert on Tue Jan 06, 2009 2:54 pm
When you have worked out what to do, I would strongly advise you to create some Java helper methods to do the boilerplate stuff, otherwise your code will look very messy. |
|
Back to top |
|
 |
NAIDU |
Posted: Wed May 10, 2017 12:38 pm Post subject: |
|
|
Novice
Joined: 12 Jan 2016 Posts: 17
|
It quite opposite to my requirement.
now i have tried :
MbElement XMLNSC=outputroot.createElementAsLastChild(MbXMLNSC.PARSER_NAME);
MbElement getCustomerSubscriptionInfoResponse=XMLNSC.createElementAsLastChild(MbElement.TYPE_NAME,"getCustomerSubscriptionInfoResponse",null);
getCustomerSubscriptionInfoResponse.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "xmlns:out7", "http://wsdl.ussco.com/CustomerSubscription/CustomerSubscriptionInterface");
getCustomerSubscriptionInfoResponse.createElementAsLastChild(MbXMLNSC.NAMESPACE_DECLARATION, "xmlns:out13", "http://wsdl.ussco.com/CustomerSubscription/ShowCustomerSubscription");
MbElement ShowCustomerSubscription = getCustomerSubscriptionInfoResponse.createElementAsLastChild(MbElement.TYPE_NAME,"ShowCustomerSubscription",null);
here i need to create doublenamespace for this .. in esql i found
https://www.ibm.com/support/knowledgecenter/SSKM8N_8.0.0/com.ibm.etools.mft.doc/ac67194_.htm
in similar ways i think this suits me.. i am trying tooo |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed May 10, 2017 1:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The example only shows ESQL and as I understand you are struggling in Java.
You have to look at the api and declare the namespace, then set it on the (Mb)Element. Use the setNamespace method of the MbElement object.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Thu May 11, 2017 4:45 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
As mentioned, you have only created namespace declarations.
You have to run setNamespace on every MBElement to the right namespace for that element.
You have to use the *full* namespace. You can't use the namespace declaration values - out7 - but have to use "http://wsdl.ussco.com/CustomerSubscription/CustomerSubscriptionInterface" .
As timber mentions, you should write a function to do this, to make sure your code is clean, if possible. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|