Lets' go step by step
- After creating your web service in SAP, open wsadmin transaction.
- Find your web service and press Ctrl+F1 after selecting your service.
- Just click OK to new window
- In browser your web service will be shown as xml type document*
- Copy all the text in the window
- Open a new project in Eclipse and create a text(*.txt) file
- Insert copied text to this text file and save it.
- Rename file extension to wsdl (*.wsdl), you will see the change in icon
- Right click new wsdl file and click Web Services -> Generate Client
- Eclipse will generate the required classes to invoke the web service
- Create a Java class with main method. Assume that my web service name is Z_Customers and method name is getCustomers()
- In the main method copy the following I hope you will not face any difficulties
try{
//Creates new service from locator
Z_CustomersService service = new Z_CustomersServiceLocator();
System.out.println("!service called!");
//Kna1 is a Customer table of SAP, in my web service
//I just select the customer from this table. This class also
//generated by eclipse.
Kna1[] customers = new Kna1[100];
//Binding the web service
Z_Customers binding = service.getz_customersSoapBinding();
System.out.println("!service binded!");
//Tables are changeable (import/export) type in SAP so
//I have to give my table as a parameter and assign the result.
customers = binding.GetCustomers(customers);
for(int i=0; i<tcustomers.length; i++){
System.out.println(customers[i].getName());
}
} catch(RemoteException e){
e.printStackTrace();
} catch (ServiceException e) {
e.printStackTrace();
}
* Some browsers does not show, right click and view the source.