Gene, you made some interesting points:

> Namespaces are confusing

No argument here... :-)

> WSDL2Java is stomping our implementation class!

Turn on the --verbose switch to verify which files are getting emitted.  This works 
fine for me (and the functional tests).  If not, please file a bug with a test case.

> Axis docs doesn't provide details on array-of-JavaBean serialization

This is true.  Care to pitch in and write a patch for the docs for 1.1 ?
If you file an enhancement for the docs with a patch (HTML please), it will get in.

Thanks!

-- 
Tom Jordahl 
Macromedia Server Development 


-----Original Message-----
From: Gene Chuang [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 29, 2002 7:12 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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?wsdl,
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

Reply via email to