Return-Path: Delivered-To: apmail-geronimo-user-archive@www.apache.org Received: (qmail 10125 invoked from network); 19 Sep 2006 22:35:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Sep 2006 22:35:05 -0000 Received: (qmail 31688 invoked by uid 500); 19 Sep 2006 22:35:01 -0000 Delivered-To: apmail-geronimo-user-archive@geronimo.apache.org Received: (qmail 31669 invoked by uid 500); 19 Sep 2006 22:35:00 -0000 Mailing-List: contact user-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: user@geronimo.apache.org List-Id: Delivered-To: mailing list user@geronimo.apache.org Received: (qmail 31658 invoked by uid 99); 19 Sep 2006 22:35:00 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Sep 2006 15:35:00 -0700 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests=MSGID_FROM_MTA_HEADER Received: from ([72.22.71.30:2440] helo=st76.startlogic.com) by idunn.apache.osuosl.org (ecelerity 2.1 r(10620)) with ESMTP id 2C/9D-28275-09070154 for ; Tue, 19 Sep 2006 15:34:57 -0700 Message-ID: <2C.9D.28275.09070154@idunn.apache.osuosl.org> Received: (qmail 39479 invoked by uid 3128); 19 Sep 2006 22:35:05 -0000 Received: from 127.0.0.1 by st76.startlogic.com (envelope-from , uid 1002) with qmail-scanner-1.25st (clamdscan: 0.88/1245. spamassassin: 3.1.0. perlscan: 1.25st. Clear:RC:1(127.0.0.1):SA:0(0.2/5.0):. Processed in 0.824917 secs); 19 Sep 2006 22:35:05 -0000 X-Spam-Status: No, hits=0.2 required=5.0 Received: from unknown (HELO st76.startlogic.com.com) (127.0.0.1) by st76.startlogic.com with SMTP; 19 Sep 2006 22:35:04 -0000 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 From: lucian To: user@geronimo.apache.org Subject: PrefixedQName incompatible with javax.xml.soap.SOAPHeaderElement Reply-To: lucian@dudeinthemirror.com X-Origin: 216.113.169.193 Date: Tue, 19 Sep 2006 15:35:03 -0700 X-Uidl: 1158705303394533421 X-Mailer: AtMail 4.03 X-Qmail-Scanner-Message-ID: <115870530492239465@st76.startlogic.com> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi , I am trying to decompose a SOAP message and=0D I am getting the following exception :=0D =0D Exception in thread "main" java.lang.ClassCastException:=0D org.apache.axis.message.PrefixedQName incompatible with=0D javax.xml.soap.SOAPHeaderElement=0D at com.acme.dw.tri.MessageReader.displayAttributes(MessageReader.java:128)= =0D at com.acme.dw.tri.MessageReader.unmarshallMessage(MessageReader.java:106)= =0D at com.acme.dw.tri.MessageReader.main(MessageReader.java:155)=0D =0D =0D Here is the code :=0D =0D package com.acme.dw.tri;=0D =0D import java.io.FileNotFoundException;=0D import java.io.IOException;=0D import java.io.StringReader;=0D import java.util.Iterator;=0D =0D import javax.xml.soap.MessageFactory;=0D import javax.xml.soap.Name;=0D import javax.xml.soap.SOAPBody;=0D import javax.xml.soap.SOAPElement;=0D import javax.xml.soap.SOAPEnvelope;=0D import javax.xml.soap.SOAPException;=0D import javax.xml.soap.SOAPHeader;=0D import javax.xml.soap.SOAPHeaderElement;=0D import javax.xml.soap.SOAPMessage;=0D import javax.xml.soap.SOAPPart;=0D import javax.xml.transform.Source;=0D import javax.xml.transform.stream.StreamSource;=0D =0D =0D import com.acme.dw.util.FileIO;=0D import com.acme.dw.util.JWhich;=0D =0D /**=0D * @author l=0D *=0D */=0D public class MessageReader {=0D =0D /**=0D * =0D */=0D public MessageReader () {=0D =0D }=0D =0D /**=0D * Read a SOAP message from a flat file=0D * @param _message_file=0D * @return=0D */=0D public SOAPMessage readSOAPMessageFromFile (String _message_file) {=0D String msg =3D "";=0D SOAPMessage soap_msg =3D null;=0D try {=0D msg =3D FileIO.readFileIntoStr(_message_file);=0D } catch (FileNotFoundException fnfe) {=0D System.out.println("Can not read " + _message_file);=0D fnfe.getMessage();=0D fnfe.printStackTrace();=0D } catch (IOException e) {=0D System.out.println("Other exception in readSOAPMessageFromFile");=0D e.getMessage();=0D e.printStackTrace();=0D }=0D =0D // If you don't have the FileIO package read from the file like this:=0D // FileInputStream fis=3D new FileInputStream(_message_file); =0D // StreamSource src =3D new StreamSource(fis); =0D =0D =0D // Make the string into a javax.xml.soap.SOAPMessage=0D try {=0D MessageFactory factory =3D MessageFactory.newInstance();=0D soap_msg =3D factory.createMessage();=0D SOAPPart sp =3D soap_msg.getSOAPPart();=0D =0D StringReader char_stream =3D new StringReader(msg); = =0D Source src =3D new StreamSource(char_stream);=0D =0D sp.setContent(src);=0D =0D soap_msg.saveChanges();=0D }=0D catch (SOAPException se) {=0D System.out.println("SOAPException in readSOAPMessageFromFile");=0D se.getMessage();=0D se.printStackTrace();=0D return null;=0D }=0D =0D return soap_msg;=0D }=0D =0D /**=0D * Given a SOAP message in a string, it displays all the elements and attr= ibutes=0D * @param _tag=0D * @return=0D */=0D public String unmarshallMessage (SOAPMessage _soap_msg) {=0D SOAPEnvelope envelope =3D null;=0D try {=0D envelope =3D _soap_msg.getSOAPPart().getEnvelope(); =0D SOAPHeader header =3D envelope.getHeader();=0D SOAPBody body =3D envelope.getBody();=0D =0D Iterator allhe =3D=0D (Iterator)header.examineAllHeaderElements();=0D =0D SOAPHeaderElement she =3D null;=0D while(allhe.hasNext()) {=0D she =3D (SOAPHeaderElement)allhe.next();=0D Iterator attr =3D she.getAllAttributes();=0D displayAttributes(attr);=0D =0D boolean mu =3D she.getMustUnderstand();=0D System.out.println("mustUnderstand is : " + mu);=0D }=0D =0D =0D =0D } catch (SOAPException se) {=0D System.out.println("SOAPException in unmarshallMessage");=0D se.getMessage();=0D se.printStackTrace();=0D =0D }=0D return null;=0D }=0D =0D =0D private void displayAttributes (Iterator _attr) {=0D =0D while (_attr.hasNext()) {=0D =0D SOAPElement se =3D (SOAPHeaderElement)_attr.next();=0D =0D Name se_name =3D se.getElementName();=0D System.out.println("Attribute name : " + se_name);=0D System.out.println("Attribute text : " +=0D se.getAttributeValue(se_name)); =0D } =0D }=0D =0D =0D /**=0D * @param args=0D */=0D public static void main(String[] args) {=0D if (args.length < 1) {=0D System.out.println("USAGE : " + FileIO.class.getName() + "");=0D System.out.println(" is the file that contains the S= OAP=0D message");=0D return;=0D }=0D =0D // where is the class loaded from=0D JWhich.which ("javax.xml.soap.MessageFactory");=0D // JWhich.which("javax.xml.soap.SOAPHeaderElement");=0D =0D String _file =3D args[0];=0D MessageReader mr =3D new MessageReader();=0D SOAPMessage sm =3D mr.readSOAPMessageFromFile(_file);=0D mr.unmarshallMessage(sm);=0D =0D }=0D =0D }=0D =0D And here is the list under the "Order and Export" tab=0D in Eclipse --> Project --> Properties --> Java Build Path=0D =0D tri/src=0D util=0D Geronimo v1.1 Runtime=0D commons-discovery-0.2.jar=0D axis-1.4.jar=0D jdom-1.0.jar=0D JRE System Library [ibm_jdk_15]=0D =0D =0D I've tried to use the JRE 1.4.2 from Sun instead, I'm getting=0D exactly the same exception (according to the Geronimo doc=0D one can use 1.5 as long as CORBA support is not needed)=0D =0D =0D Thanks in advance for your help. =0D Of course, if you know of a better / simpler way to do this, that=0D would help as well.=0D =0D =0D =0D