WSDL in SAP – Part II -How to Create, Consume and Troubleshoot SAP Web Service Consumer?

Very often we have a business need to connect to the external third-party system from within SAP environment using external web service to pull information.

In layman terms, there are some data present in the external system and is needed in SAP system. To achieve this we would need to create SAP Web Service Consumer to call external web service from SAP system.

A Web Service is needed which is external to SAP. Either create one or make sure one is made available to you. All you need is some WSDL URL. In this WSDL article, I will try to show how to access the binding and include the URLs for all the bindings defined for a service.

Steps

Assuming we have been provided a WSDL (shown above) to use from within ABAP, we would go to the SAP system and follow the steps as described below.

Use Transaction SE80. Open Package in which you want to create the service and go to Enterprise Services and right click on ‘Create’.

A pop-up will appear. Select Service Consumer option and click ‘Cont.’. We are selecting Service Consumer as we are consuming external service into SAP environment.

For the Service Consumer source, we can choose amongst ‘Backend’, Enterprise Service Repository, External WSDL/Schema. Please select External WSDL/Schema and press continue.

We can choose amongst Local file, URL, HTTP Destination and Service Registry. Choose URL option and click on Continue.

Enter the WSDL in the URL path and click on continue.

You might get issues on clicking ‘Continue’ after entering WSDL in URL path. I encountered below issues and am documenting the same for reference.

ISSUE # 1 – Exception occurred in communication framework: Connection refused.

Resolution –

This issue comes when the firewall is not open for this system. Raise a ticket with Infrastructure Security team to get firewall open for this system and issue will be resolved.

ISSUE # 2 Exception occurred in library handler.

Resolution –

In Table SPROXSET set name NO_RPC_STYLE to value ‘X’ against your user id. Basically, this will bypass SIDL library and error will not come.

In the next step, it will ask for TR details and package assignment. Enter the details and press continue to finish the Consumer Service creation.

ISSUE # 3 – Logical port template is inconsistent, regenerate and activate it

We were getting the below error ‘Logical port template is inconsistent, regenerate and activate it’ whenever we were trying to open any service consumer.

Resolution-

For this, I found one SAP Note 2315041 which we implemented and error got resolved.

Once consumer service is created, proxy class and methods will get created automatically which will be consumed in ABAP report.

Still, it is not ready for use. You need to get the logical port for the consumer proxy created and here comes the role of BASIS team. A logical port is created for a specific consumer proxy to access one particular binding on the provider system. Raise a ticket to BASIS team to create the logical port.

Go to t-code SOAMANAGER.

Click on Web Service Configuration. Search with object name as your proxy class name.

Click on the internal name and you will be navigated to below screen where details of the logical port will be shown. Once the logical port is created by BASIS team, an entry will be created

Quick Testing

It’s also possible to test the Consumer Proxy without creating a program, using transaction SE80. Follow these steps to trigger a test-call:

  1. Go to transaction SE80 and display the Consumer Proxy object (Edit Object > Enhanced Options > Enterprise Services > Client Proxy).
  2. Click on the Test (F8)
  3. On the selection screen specify the Logical Portand select the Method.
  4. Click on Execute (F8).
  5. With the XML Editor (Ctrl+F2)you can edit the input values of the request XML.
  6. To trigger the call, click on Execute (F8).

Now the fun part. How to call the web service from ABAP?

Create an instance of the proxy class passing the logical port name.

Then call the proxy method to get the data into the internal table as.

ISSUE # 4 – Authenticate SOAP:1,027 SRT: Serialization / Deserialization Failed

While trying to consume the proxy, if below exception is thrown when executing the call to the web service method.

“SOAP:1,027 SRT: Serialization / Deserialization Failed”

You need to make sure for any date field about the data type used. ABAP type needs to be ISO format if it gives the error on testing: