I think you should register type mapping for Param also in the
Client.java as ur return type is of type Param
> ------------------------------------------ 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:PublicService2", "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));
> Param result=null;
> try {
> call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
> call.setOperationName( new QName("PublicService2",
> "getSingleBusinessLocation") );
> call.addParameter( "arg1", qn, ParameterMode.IN );
> call.setReturnClass(Param.class);
> result = (Param) 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("------------------------");
> String name = result.getName();
> String value = (String)result.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="PublicService2" provider="java:RPC" style="wrapped">
> <parameter name="className" value="apacheaxis.PublicService2"/>
> <parameter name="allowedMethods" value="getSingleBusinessLocation"/>
> <beanMapping qname="myNS:Request" xmlns:myNS="urn:PublicService2"
> languageSpecificType="java:apacheaxis.Request"/>
> <beanMapping qname="myNS:Param" xmlns:myNS="urn:PublicService2"
> languageSpecificType="java:apacheaxis.Param"/>
> <typeMapping qname="myNS:Param" xmlns:myNS="urn:PublicService2"
> languageSpecificType="java:apacheaxis.Param"
> deserializer="apacheaxis.ParamDeserFactory"/>
> </service>
> </deployment>
>
> Using the above code I was getting No Deserializer found for class Param. So I wrote
> one as follow:
>
> ----------------------------------------------Deserializer-----------------------------------
> public class ParamDeser extends DeserializerImpl
> {
> public static final String NAME = "name";
> public static final String VALUE = "vlaue";
> public static final QName myTypeQName = new QName("typeNS", "Param");
>
> private Hashtable typesByMemberName = new Hashtable();
>
> public ParamDeser()
> {
> typesByMemberName.put(NAME, Constants.XSD_STRING);
> typesByMemberName.put(VALUE, Constants.XSD_ANYTYPE);
> value = new Param();
> }
>
> /** DESERIALIZER STUFF - event handlers
> */
> /**
> * This method is invoked when an element start tag is encountered.
> * @param namespace is the namespace of the element
> * @param localName is the name of the element
> * @param prefix is the element's prefix
> * @param attributes are the attributes on the element...used to get the type
> * @param context is the DeserializationContext
> */
> public SOAPHandler onStartChild(String namespace,
> String localName,
> String prefix,
> Attributes attributes,
> DeserializationContext context)
> throws SAXException
> {
> QName typeQName = (QName)typesByMemberName.get(localName);
> if (typeQName == null)
> throw new SAXException("Invalid element in Data struct - " + localName);
>
> // These can come in either order.
> Deserializer dSer = context.getDeserializerForType(typeQName);
> try {
> dSer.registerValueTarget(new FieldTarget(value, localName));
> } catch (NoSuchFieldException e) {
> throw new SAXException(e);
> }
>
> if (dSer == null)
> throw new SAXException("No deserializer for a " + typeQName + "???");
>
> return (SOAPHandler)dSer;
> }
> }
> ------------------------------------Deser factory---------------------------
> public class ParamDeserFactory implements DeserializerFactory {
> private Vector mechanisms;
> public ParamDeserFactory() {
> }
> public javax.xml.rpc.encoding.Deserializer getDeserializerAs(String
> mechanismType) {
> return new ParamDeser();
> }
> public Iterator getSupportedMechanismTypes() {
> if (mechanisms == null) {
> mechanisms = new Vector();
> mechanisms.add(Constants.AXIS_SAX);
> }
> return mechanisms.iterator();
> }
> }
>
> and here is the complete error message with the stack trace:
>
> Feb 4, 2004 10:34:07 AM org.apache.axis.client.Call invoke
> SEVERE: No returnType was specified to the Call object! You must call setReturn
> Type() if you have called addParameter().
> Feb 4, 2004 10:34:08 AM org.apache.axis.client.Call invoke
> SEVERE: Exception:
> org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which
> is NOT expected, in something it was trying to deserialize.
> at org.apache.axis.encoding.ser.SimpleDeserializer.onStartChild(SimpleDe
> serializer.java:189)
> 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:35)
> Error : org.xml.sax.SAXException: SimpleDeserializer encountered a child element
> , which is NOT expected, in something it was trying to deserialize.
> Name Value
> ------------------------
> Exception in thread "main" java.lang.NullPointerException
> at apacheaxis.Client.main(Client.java:42)
>
> Thanks so much.
> Tony.
>
> Venkatesh Kancharla <[EMAIL PROTECTED]> wrote:
> can you please post both the objects? I did face this problem long back
> and I don`t clearly remember how I solved it. Maybe after seeing the
> object, I may be able to give you some solution
>
> regards
> -------------------
> Venkatesh Kancharla
>
>
> _|_|_|_|_| _|_|_|_|_| _|_|_|_|_| _|_|_|_|_| _|_| _| _|_|_|_|_|
> _| _| _| _| _| _| _| _| _| _| _|
> _|_|_|_|_| _| _|_|_|_|_| _|_|_|_|_| _| _| _| _| _|
> _| _| _| _| _| _| _| _| _| _| _|
> _|_|_|_|_| _| _| _| _| _| _| _|_| _|_|_|_|_|
> A L G O R I T H M S F O R L I F E
>
> Strand Genomics,
> # 237, Sir C.V. Raman Avenue,
> Rajmahal Vilas,
> Bangalore, India - 560080.
> Ph no: 23618992,93, 94, 95 ext: 212
> http://www.strandgenomics.com
>
> Favorite quote:
> ---------------------------------------------------------------------
> If Necessity Is the Mother of Invention,
> then frustration Is Its Father
> -unknown
> ---------------------------------------------------------------------
>
> On Wed, 4 Feb 2004, Tony Blair wrote:
>
> > Hi Venkatesh,
> >
> > Thanks for the reply. Answer to your question is 'yes'. My bean contains another
> > bean inside. Both beans have getters and setters. None of the samples that came
> > with axis download have similiar situation. They all contain simple types.
> >
> > Initially I was getting "no deserializer found error" so I mimic the deserializer
> > code from the samples in the "encoding" sub-package and added type mapping to my
> > deploy.wsdd and no I am getting this SimpleDeserializer error!
> >
> > Do you still have any idea as why I am getting this error? Should I post my code?
> >
> > 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! SiteBuilder - Free web site building tool. Try it!