serach google for a batch file - wsdl2java - which would generate all the required java from the WSDL.
You would have to set the required parameters in one of the java files, which you have to find out. It is the class which makes the webservice call.
You will get the response object back if you have 1.properly connected to the webservice 2. you have properly set the required parameters. Look the WSDL to know what are all required parameters
You will need to generate a client to access the service with the WSDL provided.
Use Axis2 or CXF to generate the client. I find Axis2 simple enough to jump start the client stub generation and web service access.
Download the Axis2 v1.5 binary distro from their Apache site [ http://ws.apache.org/axis2/download.cgi ] and unzip on your local drive.
Set the JAVA_HOME and AXIS2_HOME path on your PC. Run the wsdl2java bat file in the bin folder of the Axis2 home directory.
You will need to provide the output directory and WSDL URL to it as parameters. The client stub would get generated in the specified directory.
Copy this files in your project (if not already there) and place in some logical project directory hierarchy (like a client sub-folder of your class files st6ructure).
Then you will need to create the ClientController class. This class will have the logic to give actual calls to the client stub and will be used from within your other classes that implement the business logic. The code in the ClientController class to give service calls follows the steps as below -
1. Get the request object from the generated client stub. This is usually named as <ServiceName>ServiceRequest. (make sure you have the generated client stub imported in this class).
2. Provide any request parameters to it by using setters.
3. Get the stub object in similar fashion as Request object and set the requestHeader object (can be null) and the request object to it.
4. Using this stub object, give a call to the remote service (you may want to set the URL of the service in the constructor firstly), and collect the return object in some variable with an appropriate datatype.
5. You now have the response - use it any way you like it !!! Its that simple !!
Hope this helps you and I have understood and answered you question properly.
THANKS SO MUCH FOR THE INPUTS.. CAN YOU GUIDE ME WHAT I SHOULD DO to connect to BASIC Authentication. I have valid username,password. But WSDL provided has basic authentication set to authenticate the users. ANY HELP in this? I don't want to be container specific settings like setting global security on the server i am using. I would like to get this from say like property files.
posted 11 years ago
I.e. i will frame it this way, My client app is calling a webservice which has basic authentication. How should i approach using java. I used wsdl2java to generate the stubs etc. But when i am actually calling the methos in the service, i am getting 401 unauthOrised..