Why getNextXMLNode returns null?

When I view my xmlNode in queryXMLNode variable tab, I get:

soap:Body
prefix1:ABC
attr_a
comment_a
prefix1:element_a
prefix1:element_b
prefix1:element_c
and so on…

Question 1:
I am trying to loop thru the node to get the data. I create the Iterator with getXMLIterator, without any criteria. The first time I call getNextXMLNode, I get back null. Why am I not getting element ABC back in the 1st round?

Question 2:
prefix1 is added automatically by webMethods because there is a default namespace (xmlns=urn:something, with no prefix) defined in element ABC. Does it do any damage?

I have been seeing a lot of issues related to namespace. Is 6.5 SP2 the latest? Is there a later sp to fix some of these issues?

Please help.

Thanks.

The XML namespace and prefix “issues” that we’ve seen here on wMUsers lately have not been related to software defects, but rather to inexperience with IS and with XML in general.

Are you providing an XQL query when you create your Iterator? If so, what is the query?

Mark

soap:Body
----prefix1:ABC
----attr_a
--------comment_a
--------prefix1:element_a
--------prefix1:element_b
--------prefix1:element_c
--------and so on…

I see the above structure in queryXMLNode (I only use the query window to see the structure, not to do any actual query). The node was obtained from getBody of a soap request. In order to loop thru the loop, I passed body to node when invoking getXMLIterator. All other parameters were left as default. Then I called getNextXMLNode, expecting to get ABC back as a node. But instead, I got null value.

Please advise what I did wrong.
:sad:

I think something may be wrong with the SOAP request you are attempting to process.

I used the following request, extracted the body and then passed that to getXMLIterator followed by getNextXMLNode. That service returned a node name of “ns1:CreateOrderRequest” which is the expected behavior.

Mark

I don’t rule out the possibility that something’s wrong with my SOAP request. However, I don’t have enough experience to conclude that to the Request sender. Perhaps you could help with your expertise.

Comparing with your SOAP request, mine is different in the following ways:

  1. my request uses prefix soap:, yours use prefix SOAP-ENV:. I have a feeling wm likes SOAP-ENV but not sure if wm is OK with others as well even though it likes SOAP-ENV. My request sender refuses to make it SOAP-ENV.

  2. xmlns:SOAP-ENC=… is missing in mine. However, in my request, there is no reference to SOAP-ENC. Not sure if this is OK to omit SOAP-ENC if it is not referenced anyway?

  3. My request Envelope does not have namespaces xmlns:xsd and xmlns:xsi. Instead, xmlns:xsi is defined in the Root element of the body. But even though I prefer your way, it is still a valid soap request to do put them in Body root element, right?

  4. Your request uses explicit ns as xmlns:ns1=“urn:…”. in the Root element of your body. Mine uses default ns as xmlns=“urn:…” in the Root element of my body. I am having problem using XQL in queryXMLNode when referring to elements by name (but OK with WQL). However, default ns is a valid XML syntax and I don’t think my request sender will change this. If it causes problem in XQL queries, I can work around with WQL. But not sure if default ns is also causing problem in XMLNodeIterator.

Please advise if the above differences are acceptable to a valid SOAP request or not.:confused:

If you can remove any confidential information and post a sample request, I’ll take a look.

Differences in prefixes should never matter so long as the namespaces are defined correctly. I would assume that your service consumer is sending a valid soap envelope. What WSDL did they use to generate the request? If possible, please attach.

A web services testing tool might come in handy as it would allow you to use a WSDL to generate a valid request or allow you to quickly send a sample request to your IS using a “literal XML” view. I like the free, personal edition of SOAP Sonar, but there are other similar tools that may also do the trick.

IMHO, not using a (good) tool to test your web services is asking your service consumers to do your testing for you.

Also, what happens when you do not use a xmlNodeIterator and simply do a xmlNodeToDocument instead?

Mark

Hi,
Finally, I have got it working. All I need is to define nsDecls for getXMLIterator, giving a prefix to the default ns. It will return next\name based on whatever prefix I set in nsDecls and ignors the original prefix in the incoming xml.

I am finding this very flexible so that I don’t have to care if 10 different people send me request with 10 different prefix of their own. I can override with my own in nsDecls.

Thanks for everybody’s help.

Yes, that is exactly the purpose of the “nsDecls” parameter. Use it wisely, use it often. :slight_smile:

Mark