axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Blair <hrh...@yahoo.com>
Subject Re: SimpleDeserializer error
Date Thu, 05 Feb 2004 16:17:54 GMT
Hi Venkatesh,
 
Thanks for the suggestion. I slightly modified my code from yesterday where my bean takes
a Collection and my service also returns a Collection. Based on the error I get I am not sure
if the ser/deser are the problem. Here is the error and thanks for all the help you can give
me.
 
-----------error msg-------------
SEVERE: Exception:
org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> class apacheax
is.Param)
        at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:311)
        at org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:963)
        at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:198)
        at org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:722)
        at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
        at org.apache.axis.client.Call.invoke(Call.java:2272)
        at org.apache.axis.client.Call.invoke(Call.java:2171)
        at org.apache.axis.client.Call.invoke(Call.java:1691)
        at apacheaxis.Client.main(Client.java:41)
Error : org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> class
apacheaxis.Param)
 
-------------------The first bean------------------
public class Request  
{
   / ********** this bean now handles collections*************/
    private Collection params=null
    
    public Collection getParams()
    { return params; }
    public void setParams(Collection data)
    { params=data; }
    
}
------------- The 2nd bean ------------
public class Param implements java.io.Serializable
{
/********** this class remains unchanged **************/    
    private String name=null;
    private Object value=null;
    public String getName()
    { return name; }
    public void setName(String data)
    { name = data; }
    
    public Object getValue()
    { return value; }
    public void setValue(Object data)
    { value=data; }
}

-------------- The service --------------
public class PublicService3
{
  /********Service now is returning Collection *******/
    public Collection getSeveralBusinessLocation(Request req){
        Collection busLoc = new ArrayList(2);
        Param line1= new Param();
        line1.setName("LINE_1");
        line1.setValue("121 River Street");
        busLoc.add(line1);
        Param name= new Param();
        name.setName("BUSINESS_NAME");
        name.setValue("Marsh");
        busLoc.add(name);

        return busLoc;
    } 
}
------------Client ---------
public class Client
{
    public static void main(String [] args) throws Exception
    {
        Options options = new Options(args);
        
        Request req = new Request();
        
        Service  service = new Service();
        Call     call    = (Call) service.createCall();
        QName    qn      = new QName( "urn:PublicService3", "Request" );
        call.registerTypeMapping(Request.class, qn,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Request.class,
qn),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Request.class,
qn));
        call.registerTypeMapping(Param.class, qn,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Param.class,
qn),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Param.class,
qn));        
        Collection result=null;
        try {
            call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
            call.setOperationName( new QName("PublicService3", "getSeveralBusinessLocation")
);
            call.addParameter( "arg1", qn, ParameterMode.IN );
            call.setReturnClass(Param.class);
            result = (ArrayList) call.invoke( new Object[] { req } );
        } catch (AxisFault fault) {
          String  error = "Error : " + fault.toString();
          System.out.println(error);
        }
        System.out.println("Name               Value");
        System.out.println("------------------------");
        Iterator itr = result.iterator();
        while(itr.hasNext()){
            Param p = (Param)itr.next();
            String name = p.getName();
            String value = (String)p.getValue();
            System.out.println(name+"       "+value);
        }
    }
}

-----------deploy.wsdd----------------
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <service name="PublicService3" provider="java:RPC" style="wrapped">
        <parameter name="className" value="apacheaxis.PublicService3"/>
        <parameter name="allowedMethods" value="getSeveralBusinessLocation"/>
        <beanMapping qname="myNS:Request" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Request"/>
        <beanMapping qname="myNS:Param" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Param"/>
        <typeMapping qname="myNS:Param" xmlns:myNS="urn:PublicService3" languageSpecificType="java:apacheaxis.Param"
             deserializer="apacheaxis.ParamDeserFactory"/>
    </service>
</deployment>

 
Thanks,
Tony.

Venkatesh Kancharla <venkatesh@strandgenomics.com> wrote:
Have a look at org.apache.axis.encoding.ser package. It contains all the
serializers and deserializers for some collecion objects.

On Wed, 4 Feb 2004, Tony Blair wrote:

> Venkatesh,
> 
> Does Axis allow beans to have Collections as their data member?
> 
> Thanks,
> Tony.
> 
> Venkatesh Kancharla wrote:
> > 
> > Error : org.xml.sax.SAXException: SimpleDeserializer encountered a child element
> > , which is NOT expected, in something it was trying to deserialize.
> > 
> > My client is invoking a call to the service and pass it a bean that has a complex
type as a data member. Should I post the code and deploy.wsdd?
> 
> is your complex object a bean? you can only pass beans ( it should have
> setter/getter methods for all of its instance variables)
> 
> 
> > 
> > Thanks in advance.
> > 
> > 
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free web site building tool. Try it!
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!


---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online
Mime
View raw message