Wednesday, January 30, 2013

Debugging, testing and tracing SOAP messages

The past few weeks, I have been blogging about the challenges I had consuming a SOAP webservice. In this (probably) final blog on this topic, I will focus on debugging tracing an analysing the code.



While facing issues on building proper SOAP messages, a colleague pointed me an open source program called SOAPUI. This on quite some occasions really saved my day.

Download it now if you are working with SOAP based webservices and you are not using it yet.
SOAPUI enables you to upload a WSDL file (like we did in the client proxy), and simply lets you build up the SOAP message in an easy to use editor, call the webservice and see the response.

On many occasions, I downloaded my SOAP request from the payload trace in SAP (next chapter), copy-paste it in SOAPUI, and figure out the issue by trial and error, and then of course fix it in SAP. This way of working save me hours of SAP debugging I suppose.


SOAP trace in SAP

In the SOAMANAGER (transaction SOAMANAGER, opens a webdynpro application), you can edit the tracelevel. Normally, the trace would be switched off.
Switching on the trace at FULL level, enables you to see the actual SOAP message that is built up from the client proxy. If you keep getting exceptions from the webservice, this is a good place to start.

What the trace apparently also does, is add an SAP trace element to the SOAP request. In my case (probably an error in the webservice I am consuming), this caused errors (exceptions telling me that sap:trace was an unexpected element, duh). But still, I was able to download the request, which can be seen as the product of the client-proxy-SOAP-message-factory, and analyse what the problem could be. As mentioned, uploading it in SOAPUI and offering it directly to the webservice definately is a good track.


Old-school debugging

As we are calling the webservice from ABAP, we cannot do without a properly debugging. As we are working with XML-based messaging, make sure you use the XML browser option when debugging. As my specialty is not decrypting hexadecimal strings, make sure you select the option 'XML-browser' when you find yourself looking at a hexadecimal string and wonder what it represents. Good chance this is actually an XML structure.

Good luck guys and thanks for reading :-).