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 Rick Reumann <ri...@gmail.com> on 2006/03/29 23:44:07 UTC

WSDL2Java question about creating files to different package, plus few others from a newbie

First off, pardon for this newbie-ish question. I have been googling
for a long time and I'm also having difficulty finding an answer in
the archives since I'm not sure how to phrase the questions (and too
many search results on just WSDL2Java).

Anyway, I was able to follow along with this tutorial on axis that I
found very helpful
http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html?page=2 but now
I want to have my simple service return something more complicated
than an int so I decided to make a class that would return to me an
array of Employee objects.

In my com.maintenance package I have:

Employee                          //simple POJO String employeeName;
int employeeId
EmployeeMaintenance       //interface
EmployeeMaintenanceImpl //implemenation with Employee[] getEmployees method

I then used Java2WSDL:

java org.apache.axis.wsdl.Java2WSDL -o employee.wsdl
-l"http://localhost:8080/axis/services/employee" -n
urn:com.maintenance -p"com.maintenance" urn:com.maintenance
com.maintenance.EmployeeMaintenance

to make my wsdl ( generated code I pasted here
http://www.pastehere.com/?oivegh ).

Now, following how I did things from the tutorial, I use WSDL2Java to
create my stub classes. Running this from the classes dir where my
wsdl is:

java org.apache.axis.wsdl.WSDL2Java -o ..\src -d Session -s -p
com.maintenance.ws employee.wsdl.

When I look at the generated EmployeeSoapBindingImpl class in my new
package  com.maintenance.ws, it has a method signature for
getEmployees that looks like:

public com.maintenance.ws.Employee[] getEmployees()
    throws java.rmi.RemoteException {
        return null;
    }

The problem now is that I want to edit this class like I did in the
tutorial example so that I can return an Employee[] array that my
com.maintenance.EmployeeMaintenanceIpml gives me, but for some reason
the return signature on the SoapBindingImpl is using the
com.mainteance.ws.Employee class it generated in the com.mainteance.ws
package (not the package com.maintenance  ).

If rather than try to to build the stub classes to a new package with
WSDL2Java, I instead run it in the same package where I have my
initial files (Employee, EmployeeMaintenance, EmployeeMaintenaceImpl),
I end up getting Employee overwritten by the WSDL2Java command which I
guess is ok since it really is basically the same file.

In both situations, I'm also sure that this is probably a problem.
Although my classes all compile, IDEA is letting me know that for the
getEmployees() method below that

"org.apache.axis.description.typedesc not public or does not allow
instantiation."

//EmployeeSoapBindingImpl implements com.maintenance.EmployeeMaintenance
public com.maintenance.Employee[] getEmployees() throws
java.rmi.RemoteException {


I'm also running into problems trying to access getEmployees after I
deploy it (stand along access connects but getting AxisFault
NoClassDefFoundError. wsdl is out there and jar with bundled classes
in axis/web-inf/lib looks ok). But rather than tackle that issue here
(which might be related to something above), I'd like to make sure I'm
at least doing things correctly above. I've been googling but I'm
having trouble finding some good examples that demonstrate returning
back arrays of objects or collections with axis/web services.

Thanks for any help.

--
Rick

Re: WSDL2Java question about creating files to different package, plus few others from a newbie

Posted by Rick Reumann <ri...@gmail.com>.
On 3/29/06, Rick Reumann <ri...@gmail.com> wrote:
> Maybe ignore the below a bit since this image hopefully helps describe
> the issue more clearly:
>
> http://www.pastehere.com/?kndvie
>
> (I am managing to get this service to work as 'null' will return from
> my Test class, but ultimately what I want Employees being returned).

I guess it's not a big deal... I can now after using java2WSDL then
WSDL2Java, to then go back and refactor my initial
EmployeeMaintanceImp class to use the Employee instance that WSDL2java
made. I'm not sure if that's the typical approach people take though.

Re: WSDL2Java question about creating files to different package, plus few others from a newbie

Posted by Rick Reumann <ri...@gmail.com>.
Maybe ignore the below a bit since this image hopefully helps describe
the issue more clearly:

http://www.pastehere.com/?kndvie

(I am managing to get this service to work as 'null' will return from
my Test class, but ultimately what I want Employees being returned).

Thanks again for any help.

<rest of post left below for more detail, but no new comments below>

On 3/29/06, Rick Reumann <ri...@gmail.com> wrote:
> First off, pardon for this newbie-ish question. I have been googling
> for a long time and I'm also having difficulty finding an answer in
> the archives since I'm not sure how to phrase the questions (and too
> many search results on just WSDL2Java).
>
> Anyway, I was able to follow along with this tutorial on axis that I
> found very helpful
> http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html?page=2 but now
> I want to have my simple service return something more complicated
> than an int so I decided to make a class that would return to me an
> array of Employee objects.
>
> In my com.maintenance package I have:
>
> Employee                          //simple POJO String employeeName;
> int employeeId
> EmployeeMaintenance       //interface
> EmployeeMaintenanceImpl //implemenation with Employee[] getEmployees method
>
> I then used Java2WSDL:
>
> java org.apache.axis.wsdl.Java2WSDL -o employee.wsdl
> -l"http://localhost:8080/axis/services/employee" -n
> urn:com.maintenance -p"com.maintenance" urn:com.maintenance
> com.maintenance.EmployeeMaintenance
>
> to make my wsdl ( generated code I pasted here
> http://www.pastehere.com/?oivegh ).
>
> Now, following how I did things from the tutorial, I use WSDL2Java to
> create my stub classes. Running this from the classes dir where my
> wsdl is:
>
> java org.apache.axis.wsdl.WSDL2Java -o ..\src -d Session -s -p
> com.maintenance.ws employee.wsdl.
>
> When I look at the generated EmployeeSoapBindingImpl class in my new
> package  com.maintenance.ws, it has a method signature for
> getEmployees that looks like:
>
> public com.maintenance.ws.Employee[] getEmployees()
>     throws java.rmi.RemoteException {
>         return null;
>     }
>
> The problem now is that I want to edit this class like I did in the
> tutorial example so that I can return an Employee[] array that my
> com.maintenance.EmployeeMaintenanceIpml gives me, but for some reason
> the return signature on the SoapBindingImpl is using the
> com.mainteance.ws.Employee class it generated in the com.mainteance.ws
> package (not the package com.maintenance  ).
>
> If rather than try to to build the stub classes to a new package with
> WSDL2Java, I instead run it in the same package where I have my
> initial files (Employee, EmployeeMaintenance, EmployeeMaintenaceImpl),
> I end up getting Employee overwritten by the WSDL2Java command which I
> guess is ok since it really is basically the same file.
>
> In both situations, I'm also sure that this is probably a problem.
> Although my classes all compile, IDEA is letting me know that for the
> getEmployees() method below that
>
> "org.apache.axis.description.typedesc not public or does not allow
> instantiation."
>
> //EmployeeSoapBindingImpl implements com.maintenance.EmployeeMaintenance
> public com.maintenance.Employee[] getEmployees() throws
> java.rmi.RemoteException {
>
>
> I'm also running into problems trying to access getEmployees after I
> deploy it (stand along access connects but getting AxisFault
> NoClassDefFoundError. wsdl is out there and jar with bundled classes
> in axis/web-inf/lib looks ok). But rather than tackle that issue here
> (which might be related to something above), I'd like to make sure I'm
> at least doing things correctly above. I've been googling but I'm
> having trouble finding some good examples that demonstrate returning
> back arrays of objects or collections with axis/web services.
>
> Thanks for any help.
>
> --
> Rick
>


--
Rick

Re: WSDL2Java question about creating files to different package, plus few others from a newbie

Posted by Rick Reumann <ri...@gmail.com>.
On 3/29/06, Dies Koper <di...@jp.fujitsu.com> wrote:

> You wanted the method in the generated interface (and impl) to return
> com.maintenance.Employee instead of com.maintenance.ws.Employee?
> -> Don't map it to a different package.
>
> You map it to the same package and specify no separate output directory
> for the generated files. The original files get overwritten.
> -> Specify a different output directory if you don't want the original
> files to be overwritten.

Thank you Dies!! That was what I was wanting to know - and everything
is working great now. I was following this example where they have the
java files built to another package
http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html?page=2 but in
that case they were just returning type int so they weren't having to
work with a non native object.

>
>  > "org.apache.axis.description.typedesc not public or does not allow
>  > instantiation."
>
> Is that a warning or compile error? What does the code look like?
> Axis generates some extra code in the generated Javabeans to help with
> (de)serialization. They are probably accessed by classes in the
> org.apache.axis.description package, and therefore do not need to be public?

Well, I'm not really sure what it is. Typically IDEA puts things in
red that are errors and the getEmployees method of
EmployeeMaintenanceSoapBindingImpl (generated by java2WSDL) definitely
is RED, (as seen in this image from an earlier post
http://www.pastehere.com/?kndvie)  yet the whole project compiles fine
and the webservice is working great.

I'm not going to worry about I guess since things compile fine. Once
again, THANKS so much. You really helped clear up a lot of confusion.

Re: WSDL2Java question about creating files to different package, plus few others from a newbie

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Rick,

Just to make sure I understand your problem, I'll start writing what I 
understand of your e-mails.

You wrote an interface in the com.maintenance package with a method that 
returns a Employee POJO which you put in the same interface.

You then use Java2WSDL and map the package "com.maintenance" to the 
namespace "urn:com.maintenance".

You then use WSDL2Java and map the namespace to a different package: 
"com.maintenance.ws".

You wanted the method in the generated interface (and impl) to return 
com.maintenance.Employee instead of com.maintenance.ws.Employee?
-> Don't map it to a different package.

You map it to the same package and specify no separate output directory 
for the generated files. The original files get overwritten.
-> Specify a different output directory if you don't want the original 
files to be overwritten.

 > "org.apache.axis.description.typedesc not public or does not allow
 > instantiation."

Is that a warning or compile error? What does the code look like?
Axis generates some extra code in the generated Javabeans to help with 
(de)serialization. They are probably accessed by classes in the 
org.apache.axis.description package, and therefore do not need to be public?

Regards,
Dies

Rick Reumann wrote:
> First off, pardon for this newbie-ish question. I have been googling
> for a long time and I'm also having difficulty finding an answer in
> the archives since I'm not sure how to phrase the questions (and too
> many search results on just WSDL2Java).
> 
> Anyway, I was able to follow along with this tutorial on axis that I
> found very helpful
> http://www.onjava.com/pub/a/onjava/2002/06/05/axis.html?page=2 but now
> I want to have my simple service return something more complicated
> than an int so I decided to make a class that would return to me an
> array of Employee objects.
> 
> In my com.maintenance package I have:
> 
> Employee                          //simple POJO String employeeName;
> int employeeId
> EmployeeMaintenance       //interface
> EmployeeMaintenanceImpl //implemenation with Employee[] getEmployees method
> 
> I then used Java2WSDL:
> 
> java org.apache.axis.wsdl.Java2WSDL -o employee.wsdl
> -l"http://localhost:8080/axis/services/employee" -n
> urn:com.maintenance -p"com.maintenance" urn:com.maintenance
> com.maintenance.EmployeeMaintenance
> 
> to make my wsdl ( generated code I pasted here
> http://www.pastehere.com/?oivegh ).
> 
> Now, following how I did things from the tutorial, I use WSDL2Java to
> create my stub classes. Running this from the classes dir where my
> wsdl is:
> 
> java org.apache.axis.wsdl.WSDL2Java -o ..\src -d Session -s -p
> com.maintenance.ws employee.wsdl.
> 
> When I look at the generated EmployeeSoapBindingImpl class in my new
> package  com.maintenance.ws, it has a method signature for
> getEmployees that looks like:
> 
> public com.maintenance.ws.Employee[] getEmployees()
>     throws java.rmi.RemoteException {
>         return null;
>     }
> 
> The problem now is that I want to edit this class like I did in the
> tutorial example so that I can return an Employee[] array that my
> com.maintenance.EmployeeMaintenanceIpml gives me, but for some reason
> the return signature on the SoapBindingImpl is using the
> com.mainteance.ws.Employee class it generated in the com.mainteance.ws
> package (not the package com.maintenance  ).
> 
> If rather than try to to build the stub classes to a new package with
> WSDL2Java, I instead run it in the same package where I have my
> initial files (Employee, EmployeeMaintenance, EmployeeMaintenaceImpl),
> I end up getting Employee overwritten by the WSDL2Java command which I
> guess is ok since it really is basically the same file.
> 
> In both situations, I'm also sure that this is probably a problem.
> Although my classes all compile, IDEA is letting me know that for the
> getEmployees() method below that
> 
> "org.apache.axis.description.typedesc not public or does not allow
> instantiation."
> 
> //EmployeeSoapBindingImpl implements com.maintenance.EmployeeMaintenance
> public com.maintenance.Employee[] getEmployees() throws
> java.rmi.RemoteException {
> 
> 
> I'm also running into problems trying to access getEmployees after I
> deploy it (stand along access connects but getting AxisFault
> NoClassDefFoundError. wsdl is out there and jar with bundled classes
> in axis/web-inf/lib looks ok). But rather than tackle that issue here
> (which might be related to something above), I'd like to make sure I'm
> at least doing things correctly above. I've been googling but I'm
> having trouble finding some good examples that demonstrate returning
> back arrays of objects or collections with axis/web services.
> 
> Thanks for any help.
> 
> --
> Rick