You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by jcaristi <jc...@whisolutions.com> on 2008/09/29 15:07:47 UTC

Is there a bug with Axiom XPath and Multiple namespaces?

This question has been on the user forum for a few days.  After continued
research I think there may be a bug.  

Two different SOAP clients generate a similar XML request from my WSDL that
looks like the following XML document inside my service (using the
RawXMLINOutMessageReceiver):

<q1:makesGet
xmlns:q1="http://www.whisolutions.com/pss/wsdl/PartSelect-v1.0">
<makesGetParms>
<q0:UserName
xmlns:q0="http://www.whisolutions.com/pss/xsd/partselect/2008/09">Joe</q0:UserName>
<q0:Password
xmlns:q0="http://www.whisolutions.com/pss/xsd/partselect/2008/09">1</q0:Password>
<q0:Year
xmlns:q0="http://www.whisolutions.com/pss/xsd/partselect/2008/09">1998</q0:Year>
<q0:UseConfig
xmlns:q0="http://www.whisolutions.com/pss/xsd/partselect/2008/09">true</q0:UseConfig>
</makesGetParms>
</q1:makesGet>

The following code fails to find the node (using either the "selectNodes" or
the "selectSingleNode" method):

AXIOMXPath xpathExpression = new AXIOMXPath
("a:makesGet/a:makesGetParms/b:UserName"); 
xpathExpression.addNamespace("a",
"http://www.whisolutions.com/pss/wsdl/PartSelect-v1.0");
xpathExpression.addNamespace("b",
"http://www.whisolutions.com/pss/xsd/partselect/2008/09");
List nodeList = xpathExpression.selectNodes(element); 
userNode = (OMNode) xpathExpression.selectSingleNode(element);

I also tried lot's of other possible XPath expressions without success (e.g.
"a:makesGet/makesGetParms/b:UserName").  If I remove the namespaces from the
XML and the XPath expression and use an XPath testing tool, it works.  Based
on XML schema rules, I believe that the node "makesGetParms" is actually in
namespace "q1", even though the element is not qualified in the document. 
Perhaps this is the root of the problem?

Here is my WSDL and XSD:

http://www.nabble.com/file/p19723540/PartSelect_v1_0.wsdl
PartSelect_v1_0.wsdl 
http://www.nabble.com/file/p19723540/PartSelect-v1.0.0.xsd
PartSelect-v1.0.0.xsd 
-- 
View this message in context: http://www.nabble.com/Is-there-a-bug-with-Axiom-XPath-and-Multiple-namespaces--tp19723540p19723540.html
Sent from the Axis - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: Is there a bug with Axiom XPath and Multiple namespaces?

Posted by jcaristi <jc...@whisolutions.com>.
This seems to be an issue that is related to how XML messages are processed
in Axis2.  I have simplified my example and have noticed that XPath
expressions function differently depending on how the XML fragment was
constructed.  I cannot get an XPath expression to work in an Axis2 service,
but I can use the exact same expression on the exact same xml fragment
(created with StaXOMBuilder), and it works.

Here is a sample XML:

<ns:makesGet
xmlns:ns="http://www.whisolutions.com/PartSelectService/2008-10-07">
	<makesGetParms>
		<PSSAccessKey>Joe</PSSAccessKey>
		<Password>1</Password>
		<Year>1998</Year>
		<UseConfig>y</UseConfig>
		<Version>2008-10-07</Version>
            <!--You may enter ANY elements at this point-->
	</makesGetParms>
</ns:makesGet>

The following code returns results when the XML was built with the
StaXOMBuilder.  It does not return results inside an Axis2 web service, for
the same fragment:

String xpathString = "/a:makesGet/makesGetParms/PSSAccessKey";
AXIOMXPath xpathExpression = new AXIOMXPath (xpathString);
xpathExpression.addNamespace("a",
"http://www.whisolutions.com/PartSelectService/2008-10-07");
List listOfNodes =  xpathExpression.selectNodes(documentElement);

In the web service, I am using the OMElement that is passed to me by the
RawXMLINOutMessageReceiver.  When I get this element, I process it as
follows, before trying the XPath:

element.build();
element.detach();

I also tried declaring the namespace:

element.declareNamespace("http://www.whisolutions.com/PartSelectService/2008-10-07",
"ns");

In Eclipse, here are the base properties of the OMElement in an Axis2 web
service (Note that when I declare the namespace, I see it, but it doesn't
make the XPath work):
     
http://www.nabble.com/file/p19860410/soap.jpg 

Here are the properties of the OMElement built by the StaxOMBuilder:

http://www.nabble.com/file/p19860410/stax.jpg 

Has anyone successfully used XPath in a web service where the WSDL has a
namespace?

Here is my current WSDL:

http://www.nabble.com/file/p19860410/PartSelect_v1_0.wsdl
PartSelect_v1_0.wsdl 


  
-- 
View this message in context: http://www.nabble.com/Is-there-a-bug-with-Axiom-XPath-and-Multiple-namespaces--tp19723540p19860410.html
Sent from the Axis - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org