You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Joe S <js...@gmail.com> on 2007/09/19 01:28:48 UTC

AXIS2 with SAAJ

I have only searched around these forums and the apache issues forums so
please forgive me if this is already stated.

Does any have a better way to get the data out of an xml node using saaj?  I
have looked at using alternatives like axiom, however, I need to modify just
about every part of my soap message to work with our middle ware.  

The SOAPBody.getElementByName("tagName").item(index).getValue() doesn't
return anything for me but null.  
SOAPElement.getTextContent() returns a TODO exception.  

Basically I have to loop through every node, check if it is a SOAPElement,
then check the LocalName, then get it's children and so on until I come to
the data I want.  then do a SOAPElement.getValue();  Like the solution
mentioned in AXIS2-3050 at https://issues.apache.org/jira/browse/AXIS2-3050

Any Suggestions?  Here is what I am working with


SOAPMessage reply = connection.call(message, destination);
SOAPBody sb = reply.getSOAPBody();
sb.Something for easier parsing than nested loops and conditionals

The reply xml from the connection.call is 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope 
	xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <xsd:startSessionResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <return xsi:type="xsd:string">sessionID</return>
  </xsd:startSessionResponse>
 </soapenv:Body>
</soapenv:Envelope>

Thank you in advance,
Joe
-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12768102
Sent from the Axis - User mailing list archive at Nabble.com.


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


RE: AXIS2 with SAAJ

Posted by Joe S <js...@gmail.com>.
That would make sense.  I appreciate you starting the issue.  I thought I was
just doing something wrong.

Thank you,
Joe


Gennady Shumakher-2 wrote:
> 
> According to my experience the AXIS2 SAAJ 1.3 implementation of
> org.w3c.domElement.getElementsByTagName and getElementsByTagNameNS do
> not search through the document tree, but at the 1st level of children
> only. 
> 
> I've opened a JIRA issue on that matter (
> https://issues.apache.org/jira/browse/WSCOMMONS-255).
> 
> -----Original Message-----
> From: westpine [mailto:westpine@ukr.net] 
> Sent: Wednesday, September 19, 2007 14:00
> To: axis-user@ws.apache.org
> Subject: Re: AXIS2 with SAAJ
> 
> 
> I'm using this code. body is SOAPBody object. 
> 
> String name =
> body.getElementsByTagName("Name").item(itemIndex).getTextContent();
> 
> --
> View this message in context:
> http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12775991
> Sent from the Axis - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12778148
Sent from the Axis - User mailing list archive at Nabble.com.


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


RE: AXIS2 with SAAJ

Posted by Gennady Shumakher <Ge...@backflipsoftware.com>.
According to my experience the AXIS2 SAAJ 1.3 implementation of
org.w3c.domElement.getElementsByTagName and getElementsByTagNameNS do
not search through the document tree, but at the 1st level of children
only. 

I've opened a JIRA issue on that matter (
https://issues.apache.org/jira/browse/WSCOMMONS-255).

-----Original Message-----
From: westpine [mailto:westpine@ukr.net] 
Sent: Wednesday, September 19, 2007 14:00
To: axis-user@ws.apache.org
Subject: Re: AXIS2 with SAAJ


I'm using this code. body is SOAPBody object. 

String name =
body.getElementsByTagName("Name").item(itemIndex).getTextContent();

--
View this message in context:
http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12775991
Sent from the Axis - User mailing list archive at Nabble.com.


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


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


Re: AXIS2 with SAAJ

Posted by Joe S <js...@gmail.com>.
Yes I am sure that the request and response messages are correct.  I used
SOAPTrace to verify this.  I have set this aside until I hear something from
apache.


westpine wrote:
> 
> Are you sure that response contains elements you are searching for? Try to
> send request from some tool and retrieve response. I use soapUI plugin for
> eclipse for this purpose.
> 

-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12860951
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AXIS2 with SAAJ

Posted by westpine <we...@ukr.net>.
Are you sure that response contains elements you are searching for? Try to
send request from some tool and retrieve response. I use soapUI plugin for
eclipse for this purpose.
-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12791599
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AXIS2 with SAAJ

Posted by Joe S <js...@gmail.com>.
Thank you for your response.  If I do exactly as you mention with my sample
xml.  "return" should be positioned (itemIndex) 0 or 1 depending on
whitespace.  I get a null pointer exception.  So I took it a step further
and ran the below and get nothing.

SOAPBody sb2 = reply.getSOAPBody();
NodeList nl2 = sb2.getElementsByTagName("return");
System.out.println("NL2 Length is: " + nl2.getLength());  //returns 0
for(int i=0; i < nl2.getLength(); i++) {
	if(nl2.item(i)!= null)  //make sure it is not whitespace but never makes it
in the for loop
		System.out.println("Return tag text:" + nl2.item(i).getTextContent());
	}

This is all within Axis2 deployed in Tomcat 5.5.23 with jdk 1.5.0_11.


westpine wrote:
> 
> I'm using this code. body is SOAPBody object. 
> 
> String name =
> body.getElementsByTagName("Name").item(itemIndex).getTextContent();
> 
> 

-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12778064
Sent from the Axis - User mailing list archive at Nabble.com.


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


Re: AXIS2 with SAAJ

Posted by westpine <we...@ukr.net>.
I'm using this code. body is SOAPBody object. 

String name =
body.getElementsByTagName("Name").item(itemIndex).getTextContent();

-- 
View this message in context: http://www.nabble.com/AXIS2-with-SAAJ-tf4477773.html#a12775991
Sent from the Axis - User mailing list archive at Nabble.com.


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