axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "McCaslin Orion" <mccaslin_or...@bah.com>
Subject RE: No deserializer defined for array type ?
Date Thu, 09 Jan 2003 15:42:20 GMT
Yes.  

I have already found Gene Chuang's posting to be very helpful.

-Orion

-----Original Message-----
From: Jason Weinstein [mailto:JWeinstein@SeeBeyond.com]
Sent: Wednesday, January 08, 2003 10:40 PM
To: axis-user@xml.apache.org
Subject: RE: No deserializer defined for array type ?


This may not answer your question, but I found this post to be very
useful (e.g., steps 1-4).

>                         -----Original Message-----
>                         From: Gene Chuang
>                         [mailto:genechuang@yahoo.com]
>                         Sent: Sunday, December 29, 2002 7:12 PM
>                         To: axis-user@xml.apache.org;
>                         jonnycattt@cablespeed.com
>                         Subject: Re: returning an array of beans (or:
>                         why i'm going insane)
>                         
>                         
>                         
>                         Heh, I went through the same rigamarole last
>                         week to get Axis to deploy my service that has
>                         an array of JavaBeans. Here's how I attacked
>                         this problem:
>                         
>                         According to the docs, just editing the
>                         deploy.wsdd to add JavaBean serialization
>                         entries should be good enough.  However,
>                         because XML namespace syntax is nearly
>                         impossible to understand, and the docs doesn't
>                         show a full example of the wsdd, I had to
>                         create just this entry manually by doing the
>                         Java2WSDL->WSDL2Java roundtripping.  Here are
>                         the steps:
>                         
>                         1)  run Java2WSDL to get the wsdl file
>                         2) copy this file to a temp directory and run
>                         "WSDL2Java -s" to get the deploy.wsdd and not
>                         have your classes stomped
>                         3) Manually edit the new deploy.wsdd, remove
>                         all the extraneous elements: 
>                         wsdlServiceElement, wsdlServicePort and
>                         wsdlPortType.  Change className back to your
>                         original service class.  And note there should
>                         be at least 2 typeMapping entries,
>                         YourJavaBean and ArrayOfYourJavaBean!  The
>                         latter is what you're missing, and is not
>                         explained in the docs.  Furthurmore, all that
>                         complex XML-namespace-to-java-package-mapping
>                         are annotated correctly.
>                         4) Replace your original wsdd with the new one
>                         and deploy.
>                         
>                         I'm sure Marc and I aren't the first or last
>                         to come across this problem.  I blame it on
>                         the following factors:
>                         
>                         - XML Namespace is possibly the most confusing
>                         spec I've ever encountered and makes it hard
>                         to handcode your own wsdl or wsdd.
>                         - Axis docs doesn't provide details on
>                         array-of-JavaBean serialization, and this
>                         practice is very common in the real business
>                         world.
>                         - WSDL2Java is stomping our implementation
>                         class!  According to the docs, "When WSDL2Java
>                         is asked to generate the implementation
>                         template (via the --server-side flag), it will
>                         ONLY generate it if it does not already
>                         exist.  If this implementation already exists,
>                         it will not be overwritten."  This is not the
>                         case!
>                         
>                         Apache can't do much about Namespace
>                         complexity, but I hope it can rectify its
>                         documents and WSDL2Java tool!
>                         
>                         Gene
>                         
>                         Marc Esher <jonnycattt@cablespeed.com> wrote: 
>                                 Hi all,
>                                 I've been struggling with this for
>                                 quite some time now, and it's time to
>                                 post as I am about to go insane. Note
>                                 that I posted this problem to the
>                                 comp.lang.programmer group before
>                                 receiving my subscription activation
>                                 for
>                                 this list. Here goes:
>                                 
>                                 I have a class that returns an array
>                                 of javabeans (ArticleBean). I want to
>                                 expose this class as a web service
>                                 using Axis. So far, I've been
>                                 successful
>                                 publishing/consuming simple web
>                                 services, but I've had no success with
>                                 anything that returns beans...even the
>                                 provided sample won't work for me.
>                                 
>                                 Here's the relevant axis code from the
>                                 web service client:
>                                 String endpoint =
>
"http://localhost:8080/ArticleSearchService/services/ArticleSearchImpl";
>                                 Service service = new Service();
>                                 Call call=null;
>                                 
>                                 call = (Call) service.createCall();
>                                 call.setTargetEndpointAddress( new
>                                 java.net.URL(endpoint) );
>                                 QName qn = new QName(
>                                 "urn:ArticleBean", "ArticleBean" );
>
call.registerTypeMapping(ArticleBean.class, qn,
>                                 new
>
org.apache.axis.encoding.ser.BeanSerializerFactory(ArticleBean.class,
qn),
>                                 new
>
org.apache.axis.encoding.ser.BeanDeserializerFactory(ArticleBean.class,
>                                 qn));
>                                 call.setOperationName( new
>                                 QName("ArticleSearchImpl",
>                                 "searchByDoi") );
>                                 call.addParameter("doi",
>                                 XMLType.XSD_STRING, ParameterMode.IN);
>                                 call.setReturnType( XMLType.SOAP_ARRAY
>                                 );
>                                 ab = (ArticleBean[]) call.invoke( new
>                                 Object [] {doi});
>                                 
>                                 And here's the deployment descriptor:
>                                 
>                                 
> xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
>                                 
>                                 
>                                 
>                                 
> languageSpecificType="java:ArticleBean"/>
>                                 
>                                 
>                                 
>                                 If I view the wsdl at
>
http://localhost:8080/ArticleSearchService/services/ArticleSearchImpl?ws
dl,
>                                 I get the following error: (snip) The
>                                 value of the attribute "xmlns:tns1" is
>                                 invalid. Prefixed namespace bindings
>                                 may not be empty
>                                 
>                                 If I invoke a the client class
>                                 (snippet above), I get "no
>                                 deserializer
>                                 defined for array type" in the error
>                                 message.
>                                 
>                                 So.....I tried another approach:
>                                 
>                                 put my ArticleSearchImpl class into a
>                                 package (ArticleSearch).
>                                 use java2wsdl on this class; then, use
>                                 wsdl2java, putting the auto-generated
>                                 files into package ArticleSearch.ws.
>                                 This worked well. however, it also
>                                 put a new version of my ArticleBean
>                                 class into this package as well, and
>                                 the
>                                 deploy.wsdd points to this bean. Then,
>                                 I use the auto-generated
>                                 ArticleSearchImplSoapBindingImpl to
>                                 wrap my original class, something like
>                                 this:
>                                 
>                                 import
>                                 ArticleSearch.ArticleSearchImpl;
>                                 public class
>                                 ArticleSearchImplSoapBindingImpl
>                                 implements
>                                 ArticleSearch.ws.ArticleSearchImpl
>                                 {
>                                 ArticleSearchImpl searcher = new
>                                 ArticleSearchImpl(); //my original
>                                 class
>                                 
>                                 public ArticleSearch.ws.ArticleBean[]
>                                 searchByAuthor(java.lang.String
>                                 author) throws
>                                 java.rmi.RemoteException {
>                                 return
>                                 searcher.searchByAuthor(author);
>                                 }
>                                 ....
>                                 }
>                                 
>                                 The problem is that my original class
>                                 returns an array of
>                                 ArticleSearch.ArticleBean, not an
>                                 array of ArticleSearch.ws.ArticleBean.
>                                 Sticking
>                                 (ArticleSearch.ws.ArticleBean[]) in
>                                 front of the return value
>                                 didn't help, either, as I suspected it
>                                 wouldn't. So now I've progressed
>                                 somewhat from my original problem, but
>                                 i'm still stuck. I cannot believe
>                                 that it's all that difficult to create
>                                 this sucker, so I know I'm doing
>                                 stupid things wrong.
>                                 
>                                 Since there is no documentation on the
>                                 axis site for returning an array of
>                                 beans, I'm appealing to you all for
>                                 help.
>                                 
>                                 Thanks.
>                                 
>                                 Marc

-----Original Message-----
From: Mark Mueller [mailto:markcmueller@yahoo.com] 
Sent: Wednesday, January 08, 2003 6:24 PM
To: axis-user@xml.apache.org
Subject: Re: No deserializer defined for array type ?

I've been trying to answer the same question myself.
Are we supposed to use:

    call.registerTypeMapping()

to do this?  Does anyone have an example of a client
that 
deserializes an array of objects?  

   Mark

--- McCaslin Orion <mccaslin_orion@bah.com> wrote:
> Hi,
> 
> I am not having success getting an array of complex
> objects deserialized in
> a simple test client.
> 
> Has anybody figured out how to solve this error?
> 
> org.xml.sax.SAXException: No deserializer defined
> for array type
> {http://object.myObject}MyObject at
>
org.apache.axis.encoding.ser.ArrayDeserializer.onStartElement(ArrayDeser
iali
> zer.java:257)
> 
> 
> The Service function:
> public MyObject[] getMyObjects() {
>       MyObject[] myObjArray = new MyObject[3];
> 	myObjArray[0]= new MyObject();
> 	myObjArray[1]= new MyObject();
> 	myObjArray[2]= new MyObject();
> 	return(myObjArray);
> }
> 
> I've seen a few of these error postings w/o answers.
> 
> In another posting, a workaround was mentioned...
> ----------------------------------------------------
> Define a class which holds your array, and make the
> new class a bean. Something like this
> 
> class Folders {
> 	Folder[] folders;
>       getter/setter functions
>
-----------------------------------------------------
> Is this really the only way?
> 
> Many thanks,
> Orion
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Mime
View raw message