RE: First row under header return null
"FIORAMORE, François" <[email protected]> Mon, 27 Sep 2004 16:20:21 -0400
| Newsgroups | gmane.text.xml.soap.devel |
|---|---|
| Message-ID | <3BD048125D828041AEE28F2325141EB51A0A69@hermes.airwidesolutions.com> |
I don't use AXIS because of some requirement I have to follow.
I use the following import:
// Standard Java API
import java.io.*;
import java.net.*;
import java.util.*;
import javax.activation.*;
import javax.xml.parsers.*;
// Classes modeling the Apache SOAP system
import org.apache.soap.*;
import org.apache.soap.rpc.*;
import org.apache.soap.util.xml.*;
import org.apache.soap.util.mime.*;
import org.apache.soap.messaging.*;
import org.apache.soap.transport.*;
// Classes modeling a mail system.
import javax.mail.internet.*;
import javax.mail.MessagingException;
// Document Object Model
import org.w3c.dom.*;
public void SubmitReq(Envelope env, SOAPContext reqCtx, SOAPContext resCtx)
throws ....stuff...
{
...code to parse the envelope and get the TransactionID out to a java
variable...
}
With the following software:
jakarta-tomcat-4.0.3.zip
j2sdk-1_4_1_07-solaris-sparc.sh
soap-bin-2.3.1.zip
Xerces-J-bin.2.2.0.zip (I may have xerces in my classpath, but I don't
really use it.)
Let me know if you find something. Thanks again.
-----Original Message-----
From: Paul Hsu [mailto:[email protected]]
Sent: Monday, September 27, 2004 3:46 PM
To: [email protected]
Subject: Re: First row under header return null
I don't know which package you use to parse the soap. I use Jakata AXIS web
service which adopt Jakata SOAP. I wrote a test code which it print the
right information.
import javax.xml.soap.*;
import java.util.Iterator;
import org.apache.axis.message.SOAPEnvelope;
import javax.xml.soap.SOAPHeader;
import java.io.*;
import org.xml.sax.*;
public class TestSoap {
public TestSoap() {
}
public static void main (String arg[])
{
String soap= "<s:Envelope
xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<s:Header>" +
"<TransactionID s:mustUnderstand=\"1\"
xmlns:mm7=\"http://www.3gpp.org/MMS/Rel5/MM7\">vas00001-sub</TransactionID>"
+
"</s:Header>" +
"<s:Body>" +
"<SubmitReq xmlns=\"urn:T-MobileAM\" orderDate=\"2004-09-01\">" +
"<MM7Version>5.3.0</MM7Version>" +
"</SubmitReq>" +
"</s:Body>" +
"</s:Envelope>";
try {
SOAPEnvelope env = new SOAPEnvelope (new StringBufferInputStream
(soap));
SOAPHeader soaph = env.getHeader ();
Iterator soape = soaph.getChildElements ();
while(soape.hasNext())
{
SOAPElement e = (SOAPElement) soape.next();
Name name = e.getElementName();
System.out.println(name.getLocalName() + ":" + e.getValue());
}
}
catch (SOAPException ex) {
}
catch (SAXException ex) {
}
}
}
----- Original Message -----
From: FIORAMORE, <mailto:[email protected]> François
To: '[email protected]' <mailto:'[email protected]'>
Sent: Monday, September 27, 2004 11:21 AM
Subject: RE: First row under header return null
Hi Paul,
Thank for the support. But is didn't work.
I try what you wrote but it keep returning me null as the value.
I just want to get the value information (TransactionID) in the following
xml envelope.
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ">
<s:Header>
<TransactionID s:mustUnderstand="1" xmlns:mm7="vas00001-sub
<http://www.3gpp.org/MMS/Rel5/MM7>
http://www.3gpp.org/MMS/Rel5/MM7">vas00001-sub</TransactionID>
</s:Header>
<s:Body>
<SubmitReq xmlns="urn:T-MobileAM" orderDate="2004-09-01">
<MM7Version>5.3.0</MM7Version>
</SubmitReq>
</s:Body>
</s:Envelope>
Sound simple enough. :)
Here the beginning of the code:
Envelope env
...
Vector headerEntries = env.getHeader().getHeaderEntries();
Element headerElement = (Element) headerEntries.firstElement();
...
...what next??? :)
System.out.println(???.getNodeName()); //Will print out TransactionID
System.out.println(???.getNodeValue()); //Will print out vas00001-sub
// I wrote getNodeName and getNodeValue, but it could be anything...as
long as it work. :)
Thank.
Ciao,
François.
-----Original Message-----
From: Paul Hsu [mailto:[email protected]]
Sent: Friday, September 24, 2004 7:19 PM
To: [email protected]
Subject: Re: First row under header return null
try this, it should work. You problem is tempElement is the right level of
layer already. Element is extends Node.
Vector headerEntries = env.getHeader().getHeaderEntries();
Element headerElement = (Element) headerEntries.firstElement();
NodeList tempNodeList = headerElement.getElementsByTagName("TransactionID");
//I want the TransactionID.
Element tempElem = (Element)tempNodeList.item(0);
System.out.println((String)tempElem.getNodeValue().trim());
----- Original Message -----
From: Paul <mailto:[email protected]> Hsu
To: [email protected] <mailto:[email protected]>
Sent: Friday, September 24, 2004 4:04 PM
Subject: Re: First row under header return null
I think you should change the code to
NodeList tempNodeList = headerElement.getElementsByTagName("TransactionID");
//I want the TransactionID.
----- Original Message -----
From: FIORAMORE, <mailto:[email protected]> François
To: '[email protected]' <mailto:'[email protected]'>
Sent: Friday, September 24, 2004 2:27 PM
Subject: First row under header return null
Hi,
I'm creating and sending the following xml to Apache SOAP:
*******************************************************************
POST /soap/servlet/messagerouter HTTP/1.1
...
...
<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ">
<s:Header>
<mm7:TransactionID s:mustUnderstand="1"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> "
xmlns:mm7="http://www.3gpp.org/MMS/Rel5/MM7
<http://www.3gpp.org/MMS/Rel5/MM7> ">vas00001-sub</mm7:TransactionID>
</s:Header>
<s:Body>
<SubmitReq xmlns="urn:Something">
<MM7Version>5.3.0</MM7Version>
</SubmitReq>
</s:Body>
</s:Envelope>
*******************************************************************
When I try to get the TransactionID value under the header, it doesn't work.
Here the code:
*******************************************************************
env is a type Envelope.
Vector headerEntries = env.getHeader().getHeaderEntries();
Element headerElement = (Element) headerEntries.firstElement();
NodeList tempNodeList = headerElement.getElementsByTagName("*"); //I want
the TransactionID.
Element tempElem = (Element)tempNodeList.item(0);
Node tempNode = tempElem.getFirstChild();
System.out.println((String)tempNode.getNodeValue().trim());
*******************************************************************
But when I use the following xml, it work:
*******************************************************************
POST /soap/servlet/messagerouter HTTP/1.1
...
...
<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> ">
<s:Header>
<temp>
<mm7:TransactionID s:mustUnderstand="1"
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/
<http://schemas.xmlsoap.org/soap/envelope/> "
xmlns:mm7="http://www.3gpp.org/MMS/Rel5/MM7
<http://www.3gpp.org/MMS/Rel5/MM7> ">vas00001-sub</mm7:TransactionID>
</temp>
</s:Header>
<s:Body>
<SubmitReq xmlns="urn:Something">
<MM7Version>5.3.0</MM7Version>
</SubmitReq>
</s:Body>
</s:Envelope>
*******************************************************************
The only different thing, is the <temp> and </temp> tag.
Is seem for some reason that the first line under the header tag can never
been read, but if you add a level between TransactionID and Header,
everything under the temp tag is reachable.
So how can I get the TransactionID without having to put the <temp> tag?
This could also be a misunderstanding from my part. Let me know.
Software involve:
Xerces-J-bin.2.2.0.zip
jakarta-tomcat-4.0.3.zip
j2sdk-1_4_1_07-solaris-sparc.sh
soap-bin-2.3.1.zip
Thank.
Ciao,
François.
François Fioramore
Project Manager
airwide solutions (formerly Schlumberger Messaging)
T: +1 (450) 646-7700 x210
M: +1 (514) 262-8540
F: +1 (450) 646-7004
1111 St-Charles St. West, 8th Floor, East Tower
Longueuil, Québec, J4K 5G4, Canada
________________________________________________________________________
airwide solutions is changing its email address format to
[email protected].
Any slb.com email addresses will be valid until 30th September 2004.
________________________________________________________________________
________________________________________________________________________
airwide solutions is changing its email address format to
[email protected].
Any slb.com email addresses will be valid until 30th September 2004.
________________________________________________________________________
________________________________________________________________________
airwide solutions is changing its email address format to [email protected].
Any slb.com email addresses will be valid until 30th September 2004.
________________________________________________________________________