I think I'll start with an apology - I was going to try recreating it from
a file, but with having what I thought was such an accurate represenation
of the Node returned from axis I didn't think it of merit. Turns out it was
a rather stupid assumption on my part.

I've used the cut and paste method below, and it seemed to work fine. I then
tried to load in the body part of the the soap envelope, and it appeared
correct too:

       Document xmlDoc = db.parse( new File("c:/soapbody.xml" ) );

       org.w3c.dom.Node el = xmlDoc.getDocumentElement();
       org.w3c.dom.Node result = el.getFirstChild();
ArrayList list = (ArrayList)Unmarshaller.unmarshal(ArrayList.class, result );
       System.out.println( "Result: " + list.get( 0 ) );

where soapbody.xml is the following ( only not as pretty printed ):

<?xml version="1.0" encoding="UTF-8" ?>
- <#> <SOAP-ENV:Body xmlns:SOAP-ENV="*http://schemas.xmlsoap.org/soap/envelope/*";>
- <#>    <array-list>
- <#>       <greeting-planet
         xmlns:xsi="*http://www.w3.org/2001/XMLSchema-instance*";
         xsi:type="*java:genbeans.GreetingPlanet*">
          <planet>Hello</planet>
          <greeting>World</greeting>
     </greeting-planet>
- <#>       <greeting-planet>
          <planet>Bonjour</planet>
          <greeting>le monde</greeting>
     </greeting-planet>
  </array-list>
</SOAP-ENV:Body>

So it would seem that the problem may be more axis specific. It does seem odd that two nodes that appear to contain the same data get treated so differently though. I'll carry on digging and try posting in the axis group there and see
if I get any luck

Thanks for your effort on this. I'll try to research further before asking such
questions again, and sorry again for taking up your time.

Steve

Stephen Bash wrote:

Steve-

Don't thank me yet... I just tried to recreate your problem and
everything works fine for me...  Here's the xml I'm using:

  <?xml version="1.0" encoding="UTF-8"?>
  <array-list>
     <greeting-planet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
          xsi:type="java:castor.pitchford.GreetingPlanet">
         <planet>Hello</planet>
         <greeting>World</greeting>
     </greeting-planet>
     <greeting-planet>
         <planet>Bonjour</planet>
         <greeting>le monde</greeting>
     </greeting-planet>
  </array-list>

Only difference (I think) is I changed the class xsi:type points to. I unmarshalled it using the following code:

   DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
   DocumentBuilder db = dbf.newDocumentBuilder();
   Document xmlDoc = db.parse( new File(
"src/castor/pitchford/arraylist.xml" ) );

   ArrayList list = (ArrayList)Unmarshaller.unmarshal(
ArrayList.class, xmlDoc );
   System.out.println( "Result: " + list.get( 0 ) );

And for completeness, here's the class I used for GreetingPlanet:

  public class GreetingPlanet {
      private String greeting;
      private String planet;

      public GreetingPlanet() {}

      public String getGreeting() { return greeting; }
      public void setGreeting( String greeting ) { this.greeting = greeting; }

      public String getPlanet() { return planet; }
      public void setPlanet( String planet ) { this.planet = planet; }

      public String toString() { return( planet + " " + greeting ); }
  }

For my own sanity, can you try creating your result node without using
Axis (i.e. paste it into a file and parse it similar to what I'm
doing) and see if you still have problems?  I ran this on the 1.0M2
jar I have, but it might also be worth it to download 1.0M4 and see if
that changes anything...

Stephen

On 4/5/06, Steve Pitchford <[EMAIL PROTECTED]> wrote:
Hello Stephen,

Thank you for the swift reply - the stacktrace produced by the exception
follows:

Error: The namespace associated with the prefix 'xsi' could not be resolved.
The namespace associated with the prefix 'xsi' could not be resolved.
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:589)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:735)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:848)
       at simplestuff.TestJDOM.unformMessage(TestJDOM.java:138)
       at simplestuff.TestJDOM.sendMessage(TestJDOM.java:67)
       at simplestuff.TestJDOM.main(TestJDOM.java:226)
Caused by: org.xml.sax.SAXException: The namespace associated with the
prefix 'xsi' could not be resolved.
       at
org.exolab.castor.xml.UnmarshalHandler.processAttributeList(UnmarshalHandler.java:3186)
       at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1429)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:245)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:110)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:584)
       ... 5 more
Caused by: org.xml.sax.SAXException: The namespace associated with the
prefix 'xsi' could not be resolved.
       at
org.exolab.castor.xml.UnmarshalHandler.processAttributeList(UnmarshalHandler.java:3186)
       at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1429)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:245)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:110)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:584)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:735)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:848)
       at simplestuff.TestJDOM.unformMessage(TestJDOM.java:138)
       at simplestuff.TestJDOM.sendMessage(TestJDOM.java:67)
       at simplestuff.TestJDOM.main(TestJDOM.java:226)
Caused by: org.xml.sax.SAXException: The namespace associated with the
prefix 'xsi' could not be resolved.
       at
org.exolab.castor.xml.UnmarshalHandler.processAttributeList(UnmarshalHandler.java:3186)
       at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1429)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:245)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProducer.java:333)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:247)
       at
org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.java:182)
       at
org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:110)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:584)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:735)
       at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:848)
       at simplestuff.TestJDOM.unformMessage(TestJDOM.java:138)
       at simplestuff.TestJDOM.sendMessage(TestJDOM.java:67)
       at simplestuff.TestJDOM.main(TestJDOM.java:226)
BUILD SUCCESSFUL (total time: 7 seconds)


Stephen Bash wrote:

Steve-

Can you post the stack trace from this error?  It would help in
localizing the problem.

Thanks,
Stephen


On 4/4/06, Steve Pitchford <[EMAIL PROTECTED]> wrote:


Hi,

I am getting the following error when trying to unmarshall an array-list
from an org.w3c.dom.Node
into castor:

Error: The namespace associated with the prefix 'xsi' could not be resolved.

I pass the following xml into an axis soap client:

<SOAP-ENV:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:java='java' xmlns:xsd='http://www.w3.org/2001/XMLSchema'
SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
<SOAP-ENV:Body>
 <array-list>
    <greeting-planet
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:type='java:genbeans.GreetingPlanet'>
       <planet>Hello</planet>
       <greeting>World</greeting>
    </greeting-planet>
    <greeting-planet>
       <planet>Bonjour</planet>
       <greeting>le monde</greeting>
    </greeting-planet>
 </array-list>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

This is then returned from Axis using the following code ( axis returns
a soap envelope):

 SOAPBody sb = envelope.getBody();
 org.w3c.dom.Node result = sb.getFirstChild();

 if ( result != null)
 {
    Unmarshaller unmar = new Unmarshaller();
    Object o = null;
    try
    {
       unmar.setValidation(true);
       o = unmar.unmarshal(c,result);
    }
    catch ( Exception e )
    {
       System.out.println("Error: "+e.toString());
    }

    return o;
 }

 return null;

I used some code I found on the web to output the xml stored in result -
I got the following:

<?xml version="1.0" encoding="UTF-8"?>
<array-list>
  <greeting-planet
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:type="java:genbeans.GreetingPlanet">
      <planet>Hello</planet>
      <greeting>World</greeting>
  </greeting-planet>
  <greeting-planet>
      <planet>Bonjour</planet>
      <greeting>le monde</greeting>
  </greeting-planet>
</array-list>

As you can see - the xsi namespace seems to be specified.

I am using Castor 1.0M2

Any help would be much appreciatted.

Cheers,

Steve


-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------




-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to