Consuming Synchronous RESTful Web Service with PI – II
Continued from my earlier blog.
The blogpost will be incomplete without mentioning an architectural constraint associated with the approach. Since we are using the dynamic configuration to store on the URL until it is invoked by the receiver adapter, we need to live with the limitation of maximum length for the value a dynamic configuration can accept. The default limit is 200 characters and SAP strongly recommends against increasing the limit. Therefore the approach is good for a RESTful web service carrying fewer parameters. One way to manage this limitation is to work with the Web Service provider towards building shorter static part in the URL, leaving more space for dynamic values.
2. GET Method
By default SOAP channel calls POST method on the target server. However in this case it was essential that GET method is invoked. This is made possible by setting the parameters for the handler
com.sap.aii.axis.soap.MessageContextPropertiesHandler as below:
Key – set soap12.webmethod
Value – GET
The screenshot in previous blog also shows this configuration.
Well, the journey is not over yet. As we embark upon testing this scenario, we are greeted by a weird error in mapping.
Although it points to mapping error, the problem lies somewhere else.
By default the SOAP adapter is configured to extract payload from SOAP Body child. However since we are not dealing with SOAP at all, there is no question of extracting the payload. The RESTful web server typically sends a response that PI accepts as an attachment. Therefore we need to train the SOAP adapter to extract the payload from attachments. The following configuration in the communication channel does the trick.
Activate the channel and execute the scenario. Voila! We are able to consume a light-weight, dynamic web service using SAP PI.
Of course , we may discover more challenges as we travel down the path of calling different flavors of RESTful web services. However there is one thing I can vouch for – the journey will always be exciting and the results enlightening..
Please feel free to share your experience / feedback on this topic.