Consuming Webservice in SAP ABAP

Step by Step instruction on how to consume webservice in SAP ABAP

Webservice which I am using is called Airport Information Webservice and it gives you tons of information about Airports around the world. This webservice has got four operations in it GetAirportInformationByCountry, GetAirportInformationByAirportCode, GetAirportInformationByCityOrAirportName and GetAirportInformationByISOCountryCode

URL: http://www.webservicex.net/airport.asmx
WSDL URL: http://www.webservicex.net/airport.asmx?WSDL

Aiport Webservice

Define Service Consumer

Start transaction SPROXY-Enterprise Repository Browser and navigate to package where you like to create Service Consumer. I am creating Service Consumer as local object so I just right clicked on  package $TMP-Username and pressed ‘Create New Object’.

You can also do this from SE80 by right-clicking and select Create->Enterprise Service

This will kick start wizard, select ‘Service Consumer’ as Object type and press Continue.

To define service consumer this wizard need WSDL, it can either access it directly from URL or you can save WSDL as file and upload it. Based on your circumstance select your option. Since WSDL I am using can be accessed directly from SAP with URL I’ve selected URL option on next screen.

Next specify WSDL url

Select the first row (one with Soap)

Specify your transport or choose local object and prefix as per your naming convention.

Finish the wizard by pressing ‘Complete’

This will create Service Consumer along with a class, do not forget to save and activate.

If you look at the generated class you will notice that it contains a method for each operation in web service. This basically means that you can now simply instantiate this class and call the method which will eventually make a call to web service operations and will return back results.

However, before we can make a successful call to web service we need to create a logical port in SOAMANAGER for Service consumer we have just created.

SOAMANAGER Configuration

Run transaction SOAMANAGER and under ‘Service Administration’ tab click on ‘Web Service Configuration’

SAOMANAGER

On next page enter object name (the class name created in service consumer) to search for then select the name once it appears in the search result.

There are various ways of creating configuration but the easiest way to create is via WSDL. As I have WSDL (url) I am going to choose Create->WSDL Based configuration.

Specify logical port name, a description and mark this as default logical port. Press Next.

On WSDL Information tab page select ‘Via HTTP Access’ and specify WSDL URL (and username password if applicable). Press Next.

Keep on Pressing next on next few screen

Next

All the information here is automatically filled. Next.

Next

Finish

Test Service Consumer

Press ‘Test’ button

Specify ‘Logical port name’ – it can be left blank as we have defined one logical port and that is a default. Select method name and press execute.

This will open up request payload, press ‘XML Editor’ button to go in change mode.

Specify input parameter, here I have specified airport code LHR (London Heathrow). Press execute.

You should now see a response back from web service with result.

One Reply to “Consuming Webservice in SAP ABAP

Leave a Reply