You might assume, in this modern age on UI5, Fiori and OData, there would be no space for Web Services. But to your surprise, Web Service is one technology which is widely used even today. As an SAP Architect, you design interfaces which consumes external Web Services in SAP or you create Web Service in SAP and external third party consumes SAP Web Services.
Last week, we created couple of simple Web Services in SAP. After our System Administration team configured the WSDL in SOAMANAGER, we provided the WSDL end point to the team who were supposed to consume SAP Web Services from third party tool. They were using dotNet (.net) to consume SAP Web Services.
But our dotNet implementing partner complained that there is some issue with the SAP Web Service and they are not able to consume it. They provided the below error information.
“soap-env:ServerWeb service processing error; more details in the web service error log on provider side (UTC timestamp 20181206151034; Transaction ID ERR74E1A27CD0170E005C081CE5DBERR)
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at SAPClientApp.Program.Main(String[] args)
The remote server returned an error: (500) Internal Server Error.
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at SAPClientApp.Program.Main(String[] args)”
For poor ABAPers like me who is struggling to learn the simple JavaScript codes for UI5 and Fiori developments, dotNet errors were Geek.
How can an ABAPer who knows just ABAP programming language suggest the .Net developer, how to consume SAP Web Service programatically?
1. How to Test SAP Web Service?
Since, our .Net implementing partner could not consume our Web Service, we planned to test it ourselves from outside SAP. We pulled the Web Service Tutorial article written in 2008 and followed the steps.
We downloaded the free SoapUI 5.4.0 tool. We did the same in 2008 and a decade after, SoapUI still remains the best tool to test SAP Web Service. Now the SoapUI is the third party. We simulated as if we are consuming SAP Web Service just like our .Net partners.
We sent the above four screenshot to our .Net friends and the next email which came was, they were able to consume the SAP Web Service successfully, But..
But.. they could consume all SAP Web Services except one. Now this is another road block in our Agile project. SAP team needs to update why .Net were not able to consume SAP Web Service in our next Scrum Stand-Up meeting.
Error message: “Web service processing error, more details in the web service log“.
2. Where can we see the Web Service Log?
Answer : In SOAMANAGER
Logs and Traces in SOAMANAGER
If you do not know have the link to your SOAMANAGER, you can just type t-code SOAMANAGER in your SAP t-code command.
From the error log we found this message “Value ? is not a valid date in accord with the XML format for ABAP“
Did you know, we can check the Web Service Log in SAP itself instead of SOAMANAGER. Check the URI of the SOAMANAGER screen on the top. It has transaction=SRT_ELOG.
3. Go to t-code SRT_ELOG to see the same log.
When we looked closely, we found we had an optional table in the Web Service which had date field. By default there was not data in the table. When the Web Service was called from SoapUI, ‘?’ was set.
Since it was a date field, SAP expected it to be blank or 0000-00-00. But since ‘?’ was being passed unknowingly, the Web Service call was failing.
Date should be pass as 0000-00-00 or left blank
4. Optional Input Parameters handling in Web Service
Once we passed the date field as blank, we were able to consume the Web Service. But, now we were not getting any output in the response.
The culprit was again ‘?’ in the optional input field. We were passing input vale in the ImName parameter but we were not passing any value in ImTaxNumber parameter. Assuming it was optional. But by default the XML was taking ‘?’. And in the SELECT statement in SAP, ‘?’ was being passed in the filter (WHERE) clause and the SELECT query failed.
Lesson Learnt: The optional parameters should remain blank in Web Service.
5. How to Test SAP Web Service from within SAP?
Go to t-code SE80. Go to Repository Information System -> Enterprise Service. Give your Web Service name or search with Wild Card. Once you have your Web Service, hit Execute (F8) button.
SE80 -> Repository Information System -> Enterprise Services
Execute the Web Service
Generate Initial Req. Template
Open the XML Editor to Input Values to the Web Service
Please note, you need to put your Input data with the XML tags properly.
Example: Federal Credit Union
If you have another field say ImTaxNumber then the tag would look like:
<ImTaxNumber>129191200</ImTaxNumber>
Web Service Test within SAP
The above testing steps might look too simple. But trust me, if someone is testing his/her Web Service, for the first time, he/she would not know it.
6. How to Update SAP ABAP Web Service End Points (URI) after making some update in the Function Module?
Once you create the Web Service from the RFC Function Module, you configure the End Points in SOAMANAGER. Then you move your Function Module and Web Service object to next environment (say quality and then to production). Your SOAMANAGER config with end points are also there in quality and production.
After few months, the business wants to add one more input parameter in the Web Service. For this you change your RFC Function Module. You activate it and test it. After is works satisfactorily, how would this new change update in the Web Service End Point?
This is a very common and valid scenario.
Go to SE80 -> Repository Information System -> Enterprise Services -> Service Definitions.
Open the Service Definition in Edit Mode. Hit the Check or Activate Button. It should open a Pop Up message. Hit Yes. It would save the change to your transport.
Once you hit Yes, it would confirm what changes were done (added or deleted). If you get no message, it is fine too.
Now, you can move the transport(s) where you have the change to your RFC and Web Service update. You do not need to do anything in SOAMANAGER. Once the transport reaches quality and production, the Web Service would work as expected.
7. Internal error check in CL_VIF_UTIL_FUNC->CHECK; inform the person responsible
You created an RFC FM. Converted it to Web Service and the end points are configured in SOAMANAGER. Then you make a major change in the RFC FM. New custom TYPES are added. The table structure is change. You are done with the RFC. Now, you want to update the Web Service.
Leisurely you try SE80 and thought you would hit activate and the Web Service would auto adjust. To your surprise, you get error message ‘Internal error check in CL_VIF_UTIL_FUNC->CHECK; inform the person responsible’. This is not how it should behave.
You try to go to External View, Internal view. No luck.
Then I go to SE84 and try to activate there. The pop up confirms for auto correction/adjust. But eventually it also gives the same error.
If you look at the error closely. All says, Type XXXX is not available. So, I go to the Types Tab.
I hit Activate button. It pops up for auto adjust message. I hit Yes. Again same error.
Now, I was worried. I tried one last time. Instead of hitting Activate, nervously I hit Check button.
Bingo. It worked. Since I changed the TYPES of the RFC, I went to Types Tab and hit the Check icon. It prompted with auto adjust information and then all green messages. Finally, I hit the Activate button again. And this time it asked for transport.
And the Web Service got activated successfully.
So next time you are not able to adjust the inconsistent service definition, you know what you need to do in SE80 or SE84.