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 Steve Weiss <sw...@hq.nasa.gov> on 2003/06/26 21:46:43 UTC

Deserialization error: org.xml.sax.SAXException: Invalid element in...

Hi,

I've just started reading this list and haven't come across this here
(although I may have missed it). I have a service deployed which seems
to be working correctly. I can access the service through a browser
with:

http://isis.saic.hq.nasa.gov/sweiss/nmis/services/ViewService?method=programView&id=21

And I get back what looks like the correct XML in the browser. My
problem occurs when I try to access the service from a Java client with:

 java ViewClient program 21

An org.xml.sax.SAXException exception is thrown when I call
call.invoke() in the client, the message is:

Invalid element in gov.nasa.hq.nmis.core.NmisItem - viewName

The problem is that the class NmisItem has no member called viewName,
although a different class (NmisView) does. The NmisView class has an
array of type NmisWindow, which in turn has an array of NmisItem. My
deploy.wsdd looks like this:

<deployment xmlns="http://xml.apache.org/axis/wsdd/"
   xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <service name="ViewService" provider="java:RPC">
     <parameter name="className" value="ViewService"/>
     <parameter name="allowedMethods" value="*"/>
     <beanMapping qname="myNS:NmisView"
        languageSpecificType="java:gov.nasa.hq.nmis.core.NmisView"/>
     <beanMapping qname="myNS:NmisWindow"
        languageSpecificType="java:gov.nasa.hq.nmis.core.NmisWindow"/>
     <beanMapping qname="myNS:NmisItem"
        languageSpecificType="java:gov.nasa.hq.nmis.core.NmisItem"/>
  </service>
</deployment>

The relevant chunk of client code is:
  ---
  Service  service = new Service();
  Call     call    = (Call)service.createCall();
  QName    qn      = new QName( "urn:ViewService", "NmisView" );

  // Bean serializer/deserializer for NmisView class
  BeanSerializerFactory bsfView =
      new BeanSerializerFactory( NmisView.class, qn );
  BeanDeserializerFactory bdsfView =
      new BeanDeserializerFactory( NmisView.class, qn ); 
  call.registerTypeMapping( NmisView.class, qn, bsfView, bdsfView );

  // Bean serializer/deserializer for NmisWindow class
  BeanSerializerFactory bsfWindow =
      new BeanSerializerFactory( NmisWindow.class, qn );
  BeanDeserializerFactory bdsfWindow =
      new BeanDeserializerFactory( NmisWindow.class, qn ); 
  call.registerTypeMapping( NmisWindow.class, qn,
                            bsfWindow, bdsfWindow );

  // Bean serializer/deserializer for NmisItem class
  BeanSerializerFactory bsfItem =
      new BeanSerializerFactory( NmisItem.class, qn );
  BeanDeserializerFactory bdsfItem =
      new BeanDeserializerFactory( NmisItem.class, qn ); 
  call.registerTypeMapping( NmisItem.class, qn, bsfItem, bdsfItem );

  call.setTargetEndpointAddress( new java.net.URL(endpointURL) );
  call.setOperationName( new QName( "ViewService", type ) );
  call.addParameter( "arg1", XMLType.XSD_INT, ParameterMode.IN);
  call.setReturnType( new QName( "myNS", "NmisView" ) );

  Object ret = call.invoke( new Object[] { id } );  // << ERROR HERE
  ---

I guess I'm a little unclear on the correct way to handle more than one
bean type object. Can anyone point me in the right direction?

Thanks in advance,

-Steve

Re: Deserialization error: org.xml.sax.SAXException: Invalid element in...

Posted by Steve Weiss <sw...@hq.nasa.gov>.
I think I fixed my problem. Apparently I needed to create a separate
QName object for each of my bean classes in the client, and use it for
the type mapping.

-Steve