25

I generated Java files from WSDL with WSDL2Java converter, but I don't know how can I use service with these files, because there are no examples. I'm implementing client side.

newbie
  • 24,286
  • 80
  • 201
  • 301
  • Are you using Axis1 or Axis2? If it is Axis2 then which data binding option have you used? What are the exact parameters you have specified to wsdl2java? – Andrey Adamovich Nov 03 '09 at 06:59
  • Axis1 and I only gave option -s wsdl_filename.wsdl and of course classpath for java including all required jars – newbie Nov 03 '09 at 07:02

2 Answers2

11

Regarding Axis2: read these these links they contain some examples:

http://ws.apache.org/axis2/1_5_1/quickstartguide.html#clients
http://ws.apache.org/axis2/1_0/userguide3.html

EDIT: Regarding Axis1: it is based on JAX-RPC and you need to instantiate stub object or use service locator to get stub instance and all WS operations will be in that. An example is given here:

public class Tester {
  public static void main(String [] args) throws Exception {
    // Make a service
    AddressBookService service = new AddressBookServiceLocator();

    // Now use the service to get a stub which implements the SDI.
    AddressBook port = service.getAddressBook();

    // Make the actual call
    Address address = new Address(...);
    port.addEntry("Russell Butek", address);
  }
}
Andrey Adamovich
  • 20,285
  • 14
  • 94
  • 132
  • 1
    I have this kind of files : ServiceBindingImpl.java ServiceBindingStub.java ServicePortType.java ServiceService.java ServiceLocator.java ... – newbie Nov 03 '09 at 07:32
  • Then just instantiate your ServiceLocator. result = new ServiceLocator().getService().() – Andrey Adamovich Nov 03 '09 at 07:38
  • 2
    For some reason ServiceLocator doesn't have getService() method. Thx for help anyway – newbie Nov 03 '09 at 07:55
3

Normally a client doesn't instantiate a stub in Web Services, you would use the service locator and call the get method. I can't tell from your question, but if you are asking a more general "Where do I get JavaDocs (or such) to better understand the API", you would have to tell use which WS you are using.

Axis User Guide

Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191
Scanningcrew
  • 760
  • 8
  • 17