Building Webservice Client using Axis

View: New views
3 Messages — Rating Filter:   Alert me  

Building Webservice Client using Axis

by Bharath_Nabble :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am working on creating a webservice and a client to access this webservice.
I am using axis2 for creating the webservice. These are the steps I followed.

1. Created a sample Convertor.java with 2 basic methods.

2. Compiled this java file to a Convertor.class.

3. Used axis provided utility 'java2wsdl.bat' to create a convertor.wsdl file.

D:\WS-Sample\classes>d:\Installed_Softwares\axis2-1.5\bin\java2wsdl.bat -cp . -of ..\convertor.wsdl
-tn urn:convertor -l http://127.0.0.1:8080/axis2/services/convertor -cn Convertor

4. Used axis provided utility 'wsdl2java.bat' to create the required java files and the build file.(Used the parameters as mentioned in the axis2 guide)

D:\WS-Sample>d:\Installed_Softwares\axis2-1.5\bin\wsdl2java.bat -uri convertor.wsdl
-p org.wssample.ws.generated -d adb -s -ss -sd -ssi

5. This step created
a) ConvertorMessageReceiverInOut.class, ConvertorSkeleton.class , ConvertorSkeletonInterface.class (NOTE THAT THERE IS NOT STUB CLASSES CREATED) in build\classes\generated folder
b) build.xml file
c) Factory classes in org\apache\ws\axis2 folder
d) Convertor.xml / services.xml in resources folder.
e) Java src files under the src folder.

6. Used the ant build 'jar.server', 'jar.client' to create the convertor.aar and Convertor-test-client.jar files.

7. Copied the .aar file into the tomcat webapps folder and I am able to view the 2 methods which I had defined.

Now the problem is I want to write a client program to consume this service. In the examples provided the java client is written which uses the Stub object, but I could not find any Stub class in the generated folder.
Please provide me some information to write a Client program to consume the services.

Re: Building Webservice Client using Axis

by Sagara :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Oct 26, 2009 at 6:19 PM, Bharath_Nabble
<bharath.krishna@...> wrote:

>
> I am working on creating a webservice and a client to access this webservice.
> I am using axis2 for creating the webservice. These are the steps I
> followed.
>
> 1. Created a sample Convertor.java with 2 basic methods.
>
> 2. Compiled this java file to a Convertor.class.
>
> 3. Used axis provided utility 'java2wsdl.bat' to create a convertor.wsdl
> file.
>
> D:\WS-Sample\classes>d:\Installed_Softwares\axis2-1.5\bin\java2wsdl.bat -cp
> . -of ..\convertor.wsdl
> -tn urn:convertor -l http://127.0.0.1:8080/axis2/services/convertor -cn
> Convertor
>
> 4. Used axis provided utility 'wsdl2java.bat' to create the required java
> files and the build file.(Used the parameters as mentioned in the axis2
> guide)
>
> D:\WS-Sample>d:\Installed_Softwares\axis2-1.5\bin\wsdl2java.bat -uri
> convertor.wsdl
> -p org.wssample.ws.generated -d adb -s -ss -sd -ssi

Please see the user guide here [1] . Add "-g " option also, it will
generate both server side and client side  codes.

[1]- http://ws.apache.org/axis2/tools/1_4_1/CodegenToolReference.html

Thanks,

>
> 5. This step created
> a) ConvertorMessageReceiverInOut.class, ConvertorSkeleton.class ,
> ConvertorSkeletonInterface.class (NOTE THAT THERE IS NOT STUB CLASSES
> CREATED) in build\classes\generated folder
> b) build.xml file
> c) Factory classes in org\apache\ws\axis2 folder
> d) Convertor.xml / services.xml in resources folder.
> e) Java src files under the src folder.
>
> 6. Used the ant build 'jar.server', 'jar.client' to create the convertor.aar
> and Convertor-test-client.jar files.
>
> 7. Copied the .aar file into the tomcat webapps folder and I am able to view
> the 2 methods which I had defined.
>
> Now the problem is I want to write a client program to consume this service.
> In the examples provided the java client is written which uses the Stub
> object, but I could not find any Stub class in the generated folder.
> Please provide me some information to write a Client program to consume the
> services.
> --
> View this message in context: http://www.nabble.com/Building-Webservice-Client-using-Axis-tp26059137p26059137.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>



--
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/

Re: Building Webservice Client using Axis

by Bharath_Nabble :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the information.
As suggested I used -g option and am able to view the 'ConvertorStub.class' generated.
Now I have used that class file in my test client.

This is the clippet of my testClient.java

---------------------------------------------------------import convertor.*;

public class testClient{


public static void main(String[] s) {
        try {
                int lNumber = 100;
                ConvertorStub lConvertorStub = new ConvertorStub("http://127.0.0.1:8080/axis2/services/Convertor");
                farenheitToCelsius(lConvertorStub);
        } catch (Exception e) {
                e.printStackTrace();
        }
}
}

------------------------
and I am getting the following exception when trying to compile this java file

------------------------------

D:\Dumps>javac -cp Convertor-test-client.jar;axis2-kernel-1.5.jar testClient.jav
a
testClient.java:12: cannot find symbol
symbol  : method farenheitToCelsius(convertor.ConvertorStub)
location: class testClient
                farenheitToCelsius(lConvertorStub);
                ^
1 error

--------------------------------
This is my Java class for which I created a web service

--------------------------------

public class Convertor {

        public float celsiusToFarenheit ( float celsius )
        {
                return (celsius * 9 / 5) + 32;
        }

        public float farenheitToCelsius ( float farenheit )
        {
                return (farenheit - 32) * 5 / 9;
        }

}

---------------------------------------------
So the farenheitToCelsius method only takes int variable.
I wrote the client looking into some of the examples in samples folder.

Can you suggest a document which would help in identifying the problem with the client program?





Sagara wrote:
On Mon, Oct 26, 2009 at 6:19 PM, Bharath_Nabble
<bharath.krishna@wipro.com> wrote:
>
> I am working on creating a webservice and a client to access this webservice.
> I am using axis2 for creating the webservice. These are the steps I
> followed.
>
> 1. Created a sample Convertor.java with 2 basic methods.
>
> 2. Compiled this java file to a Convertor.class.
>
> 3. Used axis provided utility 'java2wsdl.bat' to create a convertor.wsdl
> file.
>
> D:\WS-Sample\classes>d:\Installed_Softwares\axis2-1.5\bin\java2wsdl.bat -cp
> . -of ..\convertor.wsdl
> -tn urn:convertor -l http://127.0.0.1:8080/axis2/services/convertor -cn
> Convertor
>
> 4. Used axis provided utility 'wsdl2java.bat' to create the required java
> files and the build file.(Used the parameters as mentioned in the axis2
> guide)
>
> D:\WS-Sample>d:\Installed_Softwares\axis2-1.5\bin\wsdl2java.bat -uri
> convertor.wsdl
> -p org.wssample.ws.generated -d adb -s -ss -sd -ssi

Please see the user guide here [1] . Add "-g " option also, it will
generate both server side and client side  codes.

[1]- http://ws.apache.org/axis2/tools/1_4_1/CodegenToolReference.html

Thanks,

>
> 5. This step created
> a) ConvertorMessageReceiverInOut.class, ConvertorSkeleton.class ,
> ConvertorSkeletonInterface.class (NOTE THAT THERE IS NOT STUB CLASSES
> CREATED) in build\classes\generated folder
> b) build.xml file
> c) Factory classes in org\apache\ws\axis2 folder
> d) Convertor.xml / services.xml in resources folder.
> e) Java src files under the src folder.
>
> 6. Used the ant build 'jar.server', 'jar.client' to create the convertor.aar
> and Convertor-test-client.jar files.
>
> 7. Copied the .aar file into the tomcat webapps folder and I am able to view
> the 2 methods which I had defined.
>
> Now the problem is I want to write a client program to consume this service.
> In the examples provided the java client is written which uses the Stub
> object, but I could not find any Stub class in the generated folder.
> Please provide me some information to write a Client program to consume the
> services.
> --
> View this message in context: http://www.nabble.com/Building-Webservice-Client-using-Axis-tp26059137p26059137.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>



--
Sagara Gunathunga

Blog - http://ssagara.blogspot.com
Web - http://people.apache.org/~sagara/


-----
Sagara Gunathunga

Blog -  http://ssagara.blogspot.com 
Web - http://sagaras.awardspace.com/