This tutorial takes you through the steps involved in successfully creating a Web Service in SAP. I will be testing this Web Service (Consuming the Web Service) using a standalone application which is built on Java called SoapUI. You can download this application at
www.soapui.org.
Step 01:
Create the function module (I have created a function module named as ZWEBSERV_01) which you will be using to publish as a Web Service. I have created a simple function module which will import a company code and it will give out details of the company code. Also if I do not provide a specific company code it will return a list of company codes as tabular data. The interface of the function module is as follows:
Step 02:
Create a Service Definition for the function module. From the function builder navigate to Utilities->More Utilities->Create Web Service->From the Function Module menu. This will open up a wizard.
Give a Service Definition Name and a Description and click continue.
There is nothing to do here. Just an option for to map the function module name. Click continue.
Select a security profile for the Service Definition. I selected "Authentication with User and Password, No Transport Guarantee". Click continue.
Select the package for the object. I selected it as a local object. Click continue.
Click "Complete" at the last screen of the wizard.
Then the screen will go to the Change Service Definition screen. There are a few setting that you can change here but for this example I'm not going to change anything. Save and activate the Service Definition.
Step 03:
Do the configuration for the Service Definition in the SOAMANAGER. Run transaction SOAMANAGER and it will open the web browser and direct you to the SOA Management console. Make sure you are open this in the right client because the configurations here are client specific.
Click the "Web Service Configuration" link and enter the previously created Service Definition in the "Search Pattern" field, Select "Service Definition" from the "Search By" drop down list and click "Go". This should display the Service Definition you created in the "Search Results" list.
Select the Service Definition line and click "Apply Selection". This will open up the "Details of Service Definition" below. The "Configuration Status" should display 0 for "Services" and "Bindings".
Click the "Configurations" tab and click "Create" to create a binding for the Service Definition. Enter the "Service Name", "Description" and "New Binding Name" and click "Apply Settings". This will create a binding for the Service Definition which is used to expose the Web Service. I'm entering the same name for the all of the fields.
The configuration for the binding will open below. Select the options as in the following diagram and click "Save".

Now you have exposed the Web Service so that a consumer can access it. Click the "Open WSDL document for selected binding or service". This will open up the browser with the WSDL displayed with the binding for your Service Definition. Use that URL as the WSDL for the Web Service Consumer.
Testing/Consuming the Web Service
Step 01:
Open the SoapUI program and create a new SoapUI project. Enter the previous WSDL url in the "Initial WSDL/WADL" field.Check the create requests check box and click OK. You will probably will be asked for the login details to SAP.
The added project will be displayed to the left side and you can double click the request to open up a window which displays the request and a response. The request is the SOAP payload. Enter a company code between the <IM_BUKRS></IM_BUKRS> tag and click the submit request button. This should give the response in the window to the left.
