Author |
Message
|
ananddhavlikar |
Posted: Thu Aug 20, 2015 12:24 am Post subject: working with namespaces in JCN (XMLNSC) |
|
|
Newbie
Joined: 20 Aug 2015 Posts: 3
|
I am working with soap service. I need to extract payload and push it to file system.
Payload has 2 namespaces, which are defined at envelope level.
When I copy MB element for(payload) of incoming request , it creates multiple references for all elements belonging to particular namespace.
How to overcome this and have namespaces defined only at root xml tag. |
|
Back to top |
|
 |
ananddhavlikar |
Posted: Thu Aug 20, 2015 12:26 am Post subject: |
|
|
Newbie
Joined: 20 Aug 2015 Posts: 3
|
I have a soap webservice , which has job of extracting payload and pushing it to file system.
Here is the soap sample
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.nwslutils.com/services/UtilitiesGroup/UtilityDeleverables/UtilityEquipment/v1/" xmlns:esb="http://services.nwslutils.com/schema/EAI/Common/ESBHeader/" xmlns:v2="http://entity.nwslutils.com/ESB/cim/v2_3/">
<soapenv:Header>
<v1:ESBHeaderType>
<TransactionContext>
<esb:TransactionID>12123</esb:TransactionID>
</TransactionContext>
</v1:ESBHeaderType>
</soapenv:Header>
<soapenv:Body>
<v1:publishETARequest>
<lineModel verb="Create">
<shieldWire verb="Create">
<v2:eleId1>1</v2:eleId1>
<v2:eleId2>1</v2:eleId2>
</shieldWire>
</lineModel>
</v1:publishETARequest>
</soapenv:Body>
</soapenv:Envelope>
Expected output is as below
<?xml version="1.0" encoding="UTF-8"?>
<v1:publishETARequest xmlns:v1="http://services.nwslutils.com/services/UtilitiesGroup/UtilityDeleverables/UtilityEquipment/v1/"
xmlns:v2="http://entity.nwslutils.com/ESB/cim/v2_3/">
<lineModel verb="Create">
<shieldWire verb="Create">
<v2:eleId1>1</v2:eleId1>
<v2:eleId2>1</v2:eleId2>
</shieldWire>
</lineModel>
</v1:publishETARequest>
Where as when I extract payload (Using Java compute node & copying element tree), it creates following output, and creates multiple field level references for same namespace.
<?xml version="1.0" encoding="UTF-8"?>
<v1:publishETARequest xmlns:v1="http://services.nwslutils.com/services/UtilitiesGroup/UtilityDeleverables/UtilityEquipment/v1/"
xmlns:v2="http://entity.nwslutils.com/ESB/cim/v2_3/">
<lineModel verb="Create">
<shieldWire verb="Create">
<NS1:eleId1 xmlns:NS1="http://entity.nwslutils.com/ESB/cim/v2_3/">1</NS1:eleId1>
<NS2:eleId2 xmlns:NS2="http://entity.nwslutils.com/ESB/cim/v2_3/">1</NS2:eleId2>
</shieldWire>
</lineModel>
</v1:publishETARequest>
How to overcome this? |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Aug 20, 2015 3:33 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
In XML Terms where is the problem. Sure, they look different but that isn't my question.
Are the two XML structures logically the same?
Is the namespace set right?
Do both results validate against the design XSD?
I know that this question has been asked before. Unless there is a functional difference in the XML structures then what is the problem? _________________ 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 |
|
 |
ananddhavlikar |
Posted: Thu Aug 20, 2015 3:50 am Post subject: |
|
|
Newbie
Joined: 20 Aug 2015 Posts: 3
|
Yes both xml's are valid, problem is with downstream legacy system which is not using xsd parsing, they are treating it as a string and using tag name to retrieve data. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 20, 2015 4:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to create an XMLNSC.NameSpaceDecl to declare the namespace at root level. This way it is declared only once in the document and only referenced thereafter.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Aug 20, 2015 5:09 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
fjb_saper wrote: |
You need to create an XMLNSC.NameSpaceDecl to declare the namespace at root level. This way it is declared only once in the document and only referenced thereafter.  |
Would that really get rid of the namespace prefix before the tag name?
Is there any reason to allow the receiver to continue to NOT use a proper XML parser? The kind of hackery they are doing is really unacceptable in modern programming environments. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
smdavies99 |
Posted: Thu Aug 20, 2015 9:43 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
mqjeff wrote: |
Is there any reason to allow the receiver to continue to NOT use a proper XML parser? The kind of hackery they are doing is really unacceptable in modern programming environments. |
Exactly my thoughts. The problem with parsing a perfectly valid XML Message is THEIR PROBLEM not yours.
Yes it has been a hard day struggling with a contact admin external WebService. far too much  _________________ 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 |
|
 |
Vitor |
Posted: Thu Aug 20, 2015 9:48 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
smdavies99 wrote: |
far too much  |
Define this strange term. Exactly how far are we talking here? I certainly have never visited this strange place.
But:
smdavies99 wrote: |
The problem with parsing a perfectly valid XML Message is THEIR PROBLEM not yours |
Even:
ananddhavlikar wrote: |
system which is not using xsd parsing |
No one is saying that the system needs to validate it against an XSD, just parse it.
ananddhavlikar wrote: |
they are treating it as a string and using tag name to retrieve data |
Then they should make their lives easier and ask for a text file in a tag & value format. It's easy enough for you to generate with a DFDL schema, and saves them wading through all the < and > that they are clearly ignoring. Possible structures include (but are not limited to):
Code: |
publishETARequest:lineModel#"Create";shieldWire#"Create";eleId#1;eleId2#1;
|
Isn't that more compact, yet containing all the information they need searchable by tag? I bet they'd get performance improvements out of the reduced string manipulation. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 20, 2015 2:32 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
mqjeff wrote: |
fjb_saper wrote: |
You need to create an XMLNSC.NameSpaceDecl to declare the namespace at root level. This way it is declared only once in the document and only referenced thereafter.  |
Would that really get rid of the namespace prefix before the tag name?
Is there any reason to allow the receiver to continue to NOT use a proper XML parser? The kind of hackery they are doing is really unacceptable in modern programming environments. |
Depending on how you set the name space declaration it could. (default namespace vs named namespace)...
But I do agree with you. A decent XML parser would not worry about those details... _________________ MQ & Broker admin |
|
Back to top |
|
 |
|