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 Jacques46 <ja...@gmail.com> on 2009/04/03 18:43:25 UTC

Re: WSDL2JAVA created uncompilable Stub

Just putting in my 2 cents, because a week ago I knew nothing about Axis, and
I had to overcome some of the hurdles that have been encountered by other
posters in the past...  I hope I can avoid other people the same wasted time
that I experienced...

My environment is Eclipse 3.2.2, with the Codegen Wizard plugin.

I have used the wizard in both directions (wsdl2java and java2wsdl) in
versions 1.3 and 1.4.1 of Axis2.

About the wizard : when you go to the Axis website, you can download the
Codegen Wizard plugin for any version of Axis.  What's misleading is that
when you unzip each version (1.3 and 1.4.1), they both are contained in the
"Axis2_Codegen_Wizard_1.3.0" directory.  Having successfully created my
stubs with version 1.3 of the wizard and Axis libraries, I now wanted to
compile them with Axis2 1.4.1.  My first reaction when I downloaded the
1.4.1 wizard was to say "hmmm... seems the wizard hasn't changed since
version 1.3, because it's in the same directory name".  WRONG !  Upon
further inspection, I clearly saw that the libraries in the /lib directory
of the plugin were indeed different.

So, here are the steps I would recommend for a successful compile :

- If you're in Eclipse, EXIT !
- If you have not done so yet, download the Axis2 standard distribution
binary for the version you want, unzip it to some directory, and then create
an environment variable "AXIS2_HOME" that points to that directory.
- Download the Codegen Wizard for the Axis version you're shooting for (the
same version as the standard distribution).  Unzip it into your Eclipse's
plugins directory.  Note that if you had a previous version of the plugin
there, you're gonna have to overwrite it with this new one if they both have
the same name.
- Copy the geronimo-stax-api_1.0_spec-1.0.1.jar and
backport-util-concurrent-3.1.jar from the AXIS2_HOME/lib directory to the
Wizard's /lib directory.
- Edit the plugin.xml file of the Wizard.  You'll see in there a bunch of
<library> nodes, add 2 nodes pointing to the jars you just copied.
- Start Eclipse
- Create a new project
- In that project, import the jars from the AXIS2_HOME/lib directory (import
them in a new folder you'll call lib)
- Refresh the project
- Project properties : Add all the jars to the build path
- Create some java class that will have the methods you want your web
service to have.  Save it.
- Right-click on the project, New->, Other...
- Select Axis2 Wizards -> Axis2 Code Generator, Next.
- Select Java2WSDL
- Type the fully qualified class name, and then add the path for the class
file.  For example, if you class is com.xyz.TheClass, and your java source
is in <SomeDir>/src/com/xyz/TheClass.java, and the corresponding class file
is in <SomeDir>/bin/com/xyz/TheClass.class, then you'd enter "<SomeDir>/bin.
- Click Test Class Loading...  If it doesn't work, review previous step.
- Click Next, and you can change the options if you want, and then click
next again.
- Select to send the output to a project in the workspace, and browse to
that project.  Then give your wsdl a name, and click Finish.
- Hopefully, all went well, and if you refresh your project, you'll see the
WSDL.

Now, if you want to create client and server code for this new WSDL:

- Go in the codegen wizard again, this time select WSDL2Java, click Next.
- Select the WSDL file you've just created.  Next.
- In Codegen Option, select Custom.  Check "Generate both..." (last
checkbox).  Next.
- Browse to the project location, and Click Finish.

You should have the client and server code generated, along with a nice ant
build file.

The class you'll want to modify is <ClassName>Skeleton.java for the
server-side.  For a client to use that service, you'd instantiate
<ClassName>Stub.java.

I really hope this helps someone in the future.  It's been a frustrating
week.

Jacques.
-- 
View this message in context: http://www.nabble.com/WSDL2JAVA-created-uncompilable-Stub-tp17775033p22872262.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: WSDL2JAVA created uncompilable Stub

Posted by Amila Suriarachchi <am...@gmail.com>.
On Tue, Apr 7, 2009 at 9:15 AM, pricilla p <pr...@gmail.com> wrote:

> Hi Jacques,
>
> I am new to axis.
>
> I have to develop an web service
>
> I have followed the steps you mentioned and created a wsdl, skeleton and
> stubs.
>
> Could you pls tell me what changes i need to make it in skeleton and stub
> files
>
> Also pls tell me how to deploy this web service.
>

you have to implement your business logic at the skelton. you need to create
a .aar file to deploy it
as an axis2 service.
Please refer to user guide.

thanks,
Amila.

>
>
> Thanks,
> Pricilla.
>
>
> On Fri, Apr 3, 2009 at 11:43 AM, Jacques46 <ja...@gmail.com>wrote:
>
>>
>> Just putting in my 2 cents, because a week ago I knew nothing about Axis,
>> and
>> I had to overcome some of the hurdles that have been encountered by other
>> posters in the past...  I hope I can avoid other people the same wasted
>> time
>> that I experienced...
>>
>> My environment is Eclipse 3.2.2, with the Codegen Wizard plugin.
>>
>> I have used the wizard in both directions (wsdl2java and java2wsdl) in
>> versions 1.3 and 1.4.1 of Axis2.
>>
>> About the wizard : when you go to the Axis website, you can download the
>> Codegen Wizard plugin for any version of Axis.  What's misleading is that
>> when you unzip each version (1.3 and 1.4.1), they both are contained in
>> the
>> "Axis2_Codegen_Wizard_1.3.0" directory.  Having successfully created my
>> stubs with version 1.3 of the wizard and Axis libraries, I now wanted to
>> compile them with Axis2 1.4.1.  My first reaction when I downloaded the
>> 1.4.1 wizard was to say "hmmm... seems the wizard hasn't changed since
>> version 1.3, because it's in the same directory name".  WRONG !  Upon
>> further inspection, I clearly saw that the libraries in the /lib directory
>> of the plugin were indeed different.
>>
>> So, here are the steps I would recommend for a successful compile :
>>
>> - If you're in Eclipse, EXIT !
>> - If you have not done so yet, download the Axis2 standard distribution
>> binary for the version you want, unzip it to some directory, and then
>> create
>> an environment variable "AXIS2_HOME" that points to that directory.
>> - Download the Codegen Wizard for the Axis version you're shooting for
>> (the
>> same version as the standard distribution).  Unzip it into your Eclipse's
>> plugins directory.  Note that if you had a previous version of the plugin
>> there, you're gonna have to overwrite it with this new one if they both
>> have
>> the same name.
>> - Copy the geronimo-stax-api_1.0_spec-1.0.1.jar and
>> backport-util-concurrent-3.1.jar from the AXIS2_HOME/lib directory to the
>> Wizard's /lib directory.
>> - Edit the plugin.xml file of the Wizard.  You'll see in there a bunch of
>> <library> nodes, add 2 nodes pointing to the jars you just copied.
>> - Start Eclipse
>> - Create a new project
>> - In that project, import the jars from the AXIS2_HOME/lib directory
>> (import
>> them in a new folder you'll call lib)
>> - Refresh the project
>> - Project properties : Add all the jars to the build path
>> - Create some java class that will have the methods you want your web
>> service to have.  Save it.
>> - Right-click on the project, New->, Other...
>> - Select Axis2 Wizards -> Axis2 Code Generator, Next.
>> - Select Java2WSDL
>> - Type the fully qualified class name, and then add the path for the class
>> file.  For example, if you class is com.xyz.TheClass, and your java source
>> is in <SomeDir>/src/com/xyz/TheClass.java, and the corresponding class
>> file
>> is in <SomeDir>/bin/com/xyz/TheClass.class, then you'd enter
>> "<SomeDir>/bin.
>> - Click Test Class Loading...  If it doesn't work, review previous step.
>> - Click Next, and you can change the options if you want, and then click
>> next again.
>> - Select to send the output to a project in the workspace, and browse to
>> that project.  Then give your wsdl a name, and click Finish.
>> - Hopefully, all went well, and if you refresh your project, you'll see
>> the
>> WSDL.
>>
>> Now, if you want to create client and server code for this new WSDL:
>>
>> - Go in the codegen wizard again, this time select WSDL2Java, click Next.
>> - Select the WSDL file you've just created.  Next.
>> - In Codegen Option, select Custom.  Check "Generate both..." (last
>> checkbox).  Next.
>> - Browse to the project location, and Click Finish.
>>
>> You should have the client and server code generated, along with a nice
>> ant
>> build file.
>>
>> The class you'll want to modify is <ClassName>Skeleton.java for the
>> server-side.  For a client to use that service, you'd instantiate
>> <ClassName>Stub.java.
>>
>> I really hope this helps someone in the future.  It's been a frustrating
>> week.
>>
>> Jacques.
>> --
>> View this message in context:
>> http://www.nabble.com/WSDL2JAVA-created-uncompilable-Stub-tp17775033p22872262.html
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: WSDL2JAVA created uncompilable Stub

Posted by Jacques46 <ja...@gmail.com>.
Hi Pricilla,

I'll answer you to the best of my knowledge, which is limited to how I've
used Axis so far.

The file with the word "Skeleton" in it is the only file that you should
have to modify.  The java class that you created in the first steps (to come
up with the WSDL file) probably only contained the signatures of your web
service methods.  The Skeleton file is pretty much the equivalent of your
.java file, e.g. it only contains method signatures, but it uses SOAP object
types instead of the types that you used.

Look for your method names in the skeleton file.  There should be a comment
for each of them telling you that you need to implement them (along with a
thrown exception).  In other words, for each of your methods, remove
everything between the opening and closing braces, and start coding.

The WSDL2Java process should have also created a build.xml file.  Once your
Skeleton is coded, you can right-click this build file, and choose "Run
as...", and then "Ant Build".  This will compile your classes (skeleton
included), and create the .class files and a .aar file in the "build"
sub-directory of your project (which it will create).

The .aar file is the archive that you need to deploy to a container. 
Personnally, I use Tomcat, and so that's what I'll talk to you about.

First, you need to download and install Tomcat.  Once tomcat is installed,
you need to download and install the Axis2 War Archive FOR THE SAME VERSION
OF AXIS2 THAT YOU USED TO CREATE YOUR WEB SERVICE.  

To install the .war file, you have two options : copy it to the
<TOMCAT_HOME>/webapps directory (and restart tomcat just to make sure), or
use the "Tomcat Manager" application that comes with Tomcat.  I'll let you
search a bit for that...

Once Axis2 is installed, you can access it by going to
http://<server>:8080/axis2.  Three options will be offered there : Services,
Validate, and Admin.  You can validate your Axis2 installation with the
Validate option.

To deploy your service, again, you have two options.  1- drop your .aar file
in the <TOMCAT_HOME>/webapps/axis2/WEB-INF/services directory, or use the
deployment tool in the Admin section of axis2 (user/pass is admin/axis2). 
The deployment tool is the first option in the Admin section.

For development, I also recommend editing the
<TOMCAT_HOME>/webapps/axis2/WEB-INF/conf/axis2.xml configuration file.  The
line to edit is has "hotupdate" in it, you should set this parameter to
true.  This will make Axis re-deploy your web service every time you
overwrite the .aar file with a new one.

As for the stub, don't touch it.  It was created by WSDL2Java to match the
method signatures of your web service.  What you need to do in your client
is instantiate it, and call its methods.  It will take care of communicating
with your web service and returning you the result.

Here's a sample of my code that uses my stub.  This is the more complex
asynchronous call, for which you need to create a callback object.  The more
direct synchronous call is more intuitive... :

Dispatch request = new Dispatch();
DispatcherStub stub = new DispatcherStub("http://" + dispatcherHost +
":8080/axis2/services/Dispatcher");
Callback callback = new Callback();
callback.setId(obj.getId());
request.setId(obj.getId());
stub.startdispatch(request, callback);

I'm sure I forgot a detail or two, but that's the essence of it.


pricilla p wrote:
> 
> Hi Jacques,
> 
> I am new to axis.
> 
> I have to develop an web service
> 
> I have followed the steps you mentioned and created a wsdl, skeleton and
> stubs.
> 
> Could you pls tell me what changes i need to make it in skeleton and stub
> files
> 
> Also pls tell me how to deploy this web service.
> 
> 
> Thanks,
> Pricilla.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/WSDL2JAVA-created-uncompilable-Stub-tp17775033p22927751.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: WSDL2JAVA created uncompilable Stub

Posted by pricilla p <pr...@gmail.com>.
Hi Jacques,

I am new to axis.

I have to develop an web service

I have followed the steps you mentioned and created a wsdl, skeleton and
stubs.

Could you pls tell me what changes i need to make it in skeleton and stub
files

Also pls tell me how to deploy this web service.


Thanks,
Pricilla.


On Fri, Apr 3, 2009 at 11:43 AM, Jacques46 <ja...@gmail.com> wrote:

>
> Just putting in my 2 cents, because a week ago I knew nothing about Axis,
> and
> I had to overcome some of the hurdles that have been encountered by other
> posters in the past...  I hope I can avoid other people the same wasted
> time
> that I experienced...
>
> My environment is Eclipse 3.2.2, with the Codegen Wizard plugin.
>
> I have used the wizard in both directions (wsdl2java and java2wsdl) in
> versions 1.3 and 1.4.1 of Axis2.
>
> About the wizard : when you go to the Axis website, you can download the
> Codegen Wizard plugin for any version of Axis.  What's misleading is that
> when you unzip each version (1.3 and 1.4.1), they both are contained in the
> "Axis2_Codegen_Wizard_1.3.0" directory.  Having successfully created my
> stubs with version 1.3 of the wizard and Axis libraries, I now wanted to
> compile them with Axis2 1.4.1.  My first reaction when I downloaded the
> 1.4.1 wizard was to say "hmmm... seems the wizard hasn't changed since
> version 1.3, because it's in the same directory name".  WRONG !  Upon
> further inspection, I clearly saw that the libraries in the /lib directory
> of the plugin were indeed different.
>
> So, here are the steps I would recommend for a successful compile :
>
> - If you're in Eclipse, EXIT !
> - If you have not done so yet, download the Axis2 standard distribution
> binary for the version you want, unzip it to some directory, and then
> create
> an environment variable "AXIS2_HOME" that points to that directory.
> - Download the Codegen Wizard for the Axis version you're shooting for (the
> same version as the standard distribution).  Unzip it into your Eclipse's
> plugins directory.  Note that if you had a previous version of the plugin
> there, you're gonna have to overwrite it with this new one if they both
> have
> the same name.
> - Copy the geronimo-stax-api_1.0_spec-1.0.1.jar and
> backport-util-concurrent-3.1.jar from the AXIS2_HOME/lib directory to the
> Wizard's /lib directory.
> - Edit the plugin.xml file of the Wizard.  You'll see in there a bunch of
> <library> nodes, add 2 nodes pointing to the jars you just copied.
> - Start Eclipse
> - Create a new project
> - In that project, import the jars from the AXIS2_HOME/lib directory
> (import
> them in a new folder you'll call lib)
> - Refresh the project
> - Project properties : Add all the jars to the build path
> - Create some java class that will have the methods you want your web
> service to have.  Save it.
> - Right-click on the project, New->, Other...
> - Select Axis2 Wizards -> Axis2 Code Generator, Next.
> - Select Java2WSDL
> - Type the fully qualified class name, and then add the path for the class
> file.  For example, if you class is com.xyz.TheClass, and your java source
> is in <SomeDir>/src/com/xyz/TheClass.java, and the corresponding class file
> is in <SomeDir>/bin/com/xyz/TheClass.class, then you'd enter
> "<SomeDir>/bin.
> - Click Test Class Loading...  If it doesn't work, review previous step.
> - Click Next, and you can change the options if you want, and then click
> next again.
> - Select to send the output to a project in the workspace, and browse to
> that project.  Then give your wsdl a name, and click Finish.
> - Hopefully, all went well, and if you refresh your project, you'll see the
> WSDL.
>
> Now, if you want to create client and server code for this new WSDL:
>
> - Go in the codegen wizard again, this time select WSDL2Java, click Next.
> - Select the WSDL file you've just created.  Next.
> - In Codegen Option, select Custom.  Check "Generate both..." (last
> checkbox).  Next.
> - Browse to the project location, and Click Finish.
>
> You should have the client and server code generated, along with a nice ant
> build file.
>
> The class you'll want to modify is <ClassName>Skeleton.java for the
> server-side.  For a client to use that service, you'd instantiate
> <ClassName>Stub.java.
>
> I really hope this helps someone in the future.  It's been a frustrating
> week.
>
> Jacques.
> --
> View this message in context:
> http://www.nabble.com/WSDL2JAVA-created-uncompilable-Stub-tp17775033p22872262.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>