Author |
Message
|
bazzaa |
Posted: Sat Oct 10, 2009 1:47 am Post subject: XMLNSC: parser discards attribute |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
Hi all,
I use message flow as web service provider that refer to another services round the net and returns response back. It is in XMLNSC domain.
I'm expecting response with attributes, like <MyElement type='myType'></MyElement>, etc. But response is formatted like <MyElement><type>myType</type></MyElement>. Is there a possibility to turn it into what I'm actually expecting?
Thanks. |
|
Back to top |
|
 |
Vitor |
Posted: Sat Oct 10, 2009 5:54 am Post subject: Re: XMLNSC: parser discards attribute |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
bazzaa wrote: |
Is there a possibility to turn it into what I'm actually expecting? |
Yes - code the response so it has attributes as you expect. There's nothing in your post that describes how the message flow formats the response, or even if it reformats the response at all (rather than just passing it through from the descendant service).
You want it attributes, have attributes. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 10, 2009 9:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need also to look at the Tree and at the type of the leaf. Remember XMLNSC does not entirely behave like XMLNS  _________________ MQ & Broker admin
Last edited by fjb_saper on Mon Oct 12, 2009 4:22 am; edited 1 time in total |
|
Back to top |
|
 |
bazzaa |
Posted: Mon Oct 12, 2009 2:00 am Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
Yes, I'm preparing response by hands with attributes set explicitly. But I have a type hierarchy and client expects xsd:type value as attribute. And there are lot of messages where one item of type A has a set of child items that have type B (or A) and these items also have its own hierarchy. So recursive 'tuning' of response seems not elegant solution. I'm expecting that after I set service response to Environment tree, type attribute is set as attribute, but not as field value so it lets me to avoid that unnecessary 'tuning'. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Oct 12, 2009 2:54 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It is the job of your middle flow to take the message that is returned from the webservice, and transform it into the message that is expected.
You should not expect anything other than a complete manglement of parser specific values when you put data that belongs to a specific parser into the Environment tree that has no parser at all. Unless you have taken steps to create a child of Environment that does belong to a specific parser.
Happy Searching, you are asking a very common question. |
|
Back to top |
|
 |
bazzaa |
Posted: Mon Oct 12, 2009 8:11 am Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
Well, I see. But what does following exception mean:
(0x03000000:NameValue):Text = 'org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: The namespace prefix "xmlns" was not declared.' (CHARACTER)
Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Oct 12, 2009 8:16 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It means that you didn't add an XMLNSC.NamespaceDecl for the namespace you represent with the namespace prefix of 'xmlns'.
Take a complete user trace of your flow at debug level. Observe everything that the flow and the parsers do with your data.
 |
|
Back to top |
|
 |
bazzaa |
Posted: Mon Oct 12, 2009 3:00 pm Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
Well, tree seems ok. If I put xmlns prefix declaration then I have:
(0x03000000:NameValue):Text = 'Frame : 0 org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: The namespace prefix "xmlns" must not be declared.
...error: not declared, error: must not be declared... Seems strange...
What I do is sort of SET OutputRoot.XMLNSC.ns:Request = InputRoot.XMLNSC.ns:Response |
|
Back to top |
|
 |
bazzaa |
Posted: Mon Oct 12, 2009 3:25 pm Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
...But if I'm assigning field by field, SET InputRoot.XMLNSC.ns:Request.ns:Field1 = OutputRoot.XMLNSC.ns:Response.ns:Field1 - everything is just great. Please tell me why?
Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Oct 12, 2009 4:42 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What you should never do is declare an xmlns prefix to represent a namespace other than the xmlns as defined by the XML standards.
Now about declaring the xmlns namespace, you should not be penalized if you do and the parser you use is standard.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Oct 12, 2009 9:07 pm Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
bazzaa wrote: |
...But if I'm assigning field by field, SET InputRoot.XMLNSC.ns:Request.ns:Field1 = OutputRoot.XMLNSC.ns:Response.ns:Field1 - everything is just great. Please tell me why?
Thanks |
Are you sure the ESQL you have quoted is correct? IMHO, changing the InputRoot Folder is a no-no. _________________ 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 |
|
 |
bazzaa |
Posted: Tue Oct 13, 2009 12:26 am Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
smdavies99 wrote: |
quoted is correct? IMHO, changing the InputRoot Folder is a no-no. |
Ah, sorry. Yes, quotation isn't correct. I'm performing SET OutputRoot.XMLNSC.ns:Request.ns:Field1 = InputRoot.XMLNSC.ns:Response.ns:Field1 |
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 13, 2009 1:21 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please insert a Trace node, and post the relevent snippet of the mesage tree.
Put [code] tags around the trace node output, to preserve the indentation. |
|
Back to top |
|
 |
bazzaa |
Posted: Tue Oct 13, 2009 3:37 am Post subject: |
|
|
Novice
Joined: 29 Sep 2009 Posts: 18
|
Here is trace oupput:
Code: |
(['SOAPRoot' : 0xa3574b0]
(0x01000000:Name ):Properties = ( ['MQPROPERTYPARSER' : 0x9888c98]
(0x03000000:NameValue):MessageSet = 'MySet_I' (CHARACTER)
(0x03000000:NameValue):MessageType = NULL
(0x03000000:NameValue):MessageFormat = 'XML1' (CHARACTER)
(0x03000000:NameValue):Encoding = NULL
(0x03000000:NameValue):CodedCharSetId = NULL
(0x03000000:NameValue):Transactional = NULL
(0x03000000:NameValue):Persistence = NULL
(0x03000000:NameValue):CreationTime = NULL
(0x03000000:NameValue):ExpirationTime = NULL
(0x03000000:NameValue):Priority = NULL
(0x03000000:NameValue):ReplyIdentifier = NULL
(0x03000000:NameValue):ReplyProtocol = 'SOAP-AXIS2' (CHARACTER)
(0x03000000:NameValue):Topic = NULL
(0x03000000:NameValue):ContentType = NULL
(0x03000000:NameValue):IdentitySourceType = NULL
(0x03000000:NameValue):IdentitySourceToken = NULL
(0x03000000:NameValue):IdentitySourcePassword = NULL
(0x03000000:NameValue):IdentitySourceIssuedBy = NULL
(0x03000000:NameValue):IdentityMappedType = NULL
(0x03000000:NameValue):IdentityMappedToken = NULL
(0x03000000:NameValue):IdentityMappedPassword = NULL
(0x03000000:NameValue):IdentityMappedIssuedBy = NULL
)
(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x9198e40]
(0x01000000:Folder)http://www.my.com/my/myservice:SaveItems = (
(0x03000102:NamespaceDecl):xmlns = 'http://www.my.com/my/myservice' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my/myservice:itemToSave = (
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:ns = 'http://www.my.com/my' (CHARACTER)
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:i = 'http://www.w3.org/2001/XMLSchema-instance' (CHARACTER)
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:b = 'http://www.my.com/my/myservice' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2000/xmlns/:b = 'http://www.my.com/my/myservice' (CHARACTER)
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model1' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems = (
(0x01000000:Folder)http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model3' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems = (
(0x01000000:Folder)http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model2' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems =
(0x03000000:PCDataField)http://www.my.com/my:Id = 5 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Interval = INTERVAL '1' MINUTE (INTERVAL)
(0x03000000:PCDataField)http://www.my.com/my/myservice:ItemType = 'A' (CHARACTER)
)
(0x01000000:Folder)http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model2' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems =
(0x03000000:PCDataField)http://www.my.com/my:Id = 5 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Interval = INTERVAL '1' MINUTE (INTERVAL)
(0x03000000:PCDataField)http://www.my.com/my/myservice:ItemType = 'A' (CHARACTER)
)
(0x01000000:Folder)http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model2' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems =
(0x03000000:PCDataField)http://www.my.com/my:Id = 7 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Interval = INTERVAL '1' MINUTE (INTERVAL)
(0x03000000:PCDataField)http://www.my.com/my/myservice:ItemType = 'A' (CHARACTER)
)
(0x01000000:Folder)http://www.my.com/my:MyGeneralModel = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model2' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:ChildItems =
(0x03000000:PCDataField)http://www.my.com/my:Id = 26 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Interval = INTERVAL '1' MINUTE (INTERVAL)
(0x03000000:PCDataField)http://www.my.com/my/myservice:ItemType = 'A' (CHARACTER)
)
)
(0x03000000:PCDataField)http://www.my.com/my:Id = 3 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:CDate = TIMESTAMP '0001-01-01 00:00:00' (TIMESTAMP)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Relevance = 'RL1' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:AGuid = 'd001ef1a-c47e-42d6-a903-010bb1fc38f5' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:AType = 'AType' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:ATypeId = 'SSFDG' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Point = 1E+1 (FLOAT)
)
)
(0x03000000:PCDataField)http://www.my.com/my:Id = 3 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Checked = NULL
(0x03000000:PCDataField)http://www.my.com/my/myservice:Guid = '1240d224-f328-4859-978d-0b7aad9558fc' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my/myservice:Report = (
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:nil = TRUE (BOOLEAN)
)
(0x01000000:Folder )http://www.my.com/my/myservice:Comments = (
(0x01000000:Folder)http://www.my.com/my:Comment = (
(0x03000000:PCDataField)http://www.my.com/my:AddStr = 'STR01' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my:CommentTST = TIMESTAMP '2009-10-10 18:12:10.107' (TIMESTAMP)
(0x03000000:PCDataField)http://www.my.com/my:Id = 55 (INTEGER)
(0x03000000:PCDataField)http://www.my.com/my:OwnerId = 'o' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my:Text = 'Comm' (CHARACTER)
)
)
(0x01000000:Folder )http://www.my.com/my/myservice:Information = (
(0x01000000:Folder)http://www.my.com/my:Tests =
(0x01000000:Folder)http://www.my.com/my:Goals =
)
(0x01000000:Folder )http://www.my.com/my/myservice:DetailedInformation = (
(0x03000000:PCDataField)http://www.my.com/my:ClientId = 'Z40203' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my:ClientName = 'John' (CHARACTER)
(0x03000000:PCDataField)http://www.my.com/my:Gender = 'Female' (CHARACTER)
)
(0x03000000:PCDataField)http://www.my.com/my/myservice:Pty = 'OK' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my/myservice:Sheets =
)
)
(0x03000000:PCDataField )http://www.my.com/my/myservice:Level = 'Level1' (CHARACTER)
)
)
)
|
|
|
Back to top |
|
 |
kimbert |
Posted: Tue Oct 13, 2009 4:11 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
The problem is on the line highlighted by the arrow:
Code: |
(0x01000000:Folder):XMLNSC = ( ['xmlnsc' : 0x9198e40]
(0x01000000:Folder)http://www.my.com/my/myservice:SaveItems = (
(0x03000102:NamespaceDecl):xmlns = 'http://www.my.com/my/myservice' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my/myservice:itemToSave = (
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:ns = 'http://www.my.com/my' (CHARACTER)
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:i = 'http://www.w3.org/2001/XMLSchema-instance' (CHARACTER)
(0x03000102:NamespaceDecl)http://www.w3.org/2000/xmlns/:b = 'http://www.my.com/my/myservice' (CHARACTER)
(0x01000000:Folder )http://www.my.com/my:MyGeneralModel = (
-----> (0x03000000:PCDataField)http://www.w3.org/2000/xmlns/:b = 'http://www.my.com/my/myservice' (CHARACTER)
(0x03000000:PCDataField)http://www.w3.org/2001/XMLSchema-instance:type = 'b:Model1' (CHARACTER) |
Look at the line two places above it. That is an example of a proper xmlns attribute declaration. The highlighted line has been copied to a tree which is not owned by the XMLNSC parser ( probably the environment tree ) and has lost the parser-specific part of its field type. That is why it is being reported as a PCDataField, instead of a NamespaceDecl.
The XMLNSC writer is probably detecting a namespace which does not have a prefix, and attempts to auto-define a prefix for the xmlns namespace. Hence the error being reported by the receiver.
There are several ways to fix the problem, but until you explain in detail what is happening to the message tree it's hard to know which fix to recommend. Hint: You don't need to define your own namespace delcaration for b - you just need to avoid mangling the existing declaration when you copy the message tree around. |
|
Back to top |
|
 |
|