Hi,
I am trying to use SAP Gateway OData REST services as the data source for MBO's. I have managed to get the read of the main collection working for the first MBO. However when creating a second MBO, I'm trying to read another URI template which has a parameter, I am having an issue.
Here is an example of the URL I am trying to connect:
http://my.domain.com:8001/sap/opu/odata/ZMYSERVICE/MainCollection('12345')/Other
I have added the REST service in enterprise explorer in Mobile SDK 2.2.3 and when trying to add the Resource URI template for the above URL as
/MainCollection('{id}')/Other
I get the following error:
The URI template '/MainCollection('{id}')/Other' is invalid.
This is due to the following characters not being accepted: ( and ' and )
So in order to fix this I use the URL encoded values for those characters and it accepts them and saves my URI template.
So this works:
/MainCollection%28%27{id}%27%29)/Other
It allows me to pass in the parameter and all seems ok except for on the Gateway side when I debug the root odata service /IWCOR/CL_DS_HDLR_HTTP in method IF_HTTP_EXTENSION~HANDLE_REQUEST it passes through the following header values from SAP Mobile SDK:
~request_line | GET /sap/opu/odata/MYSERVICE/MainCollection%28%2712345%27%29/Other HTTP/1.1 |
~request_uri | /sap/opu/odata/MYSERVICE/MainCollection%28%2712345%27%29/Other |
~path | /sap/opu/odata/MYSERVICE/MainCollection%28%2712345%27%29/Other |
~path_translated | /sap/opu/odata/MYSERVICE/MainCollection('12345')/Other |
~path_info | /MYSERVICE/MainCollection('12345')/Other |
~path_info_expanded | /MYSERVICE/MainCollection('12345')/Other |
~path_translated_expanded | /sap/opu/odata/MYSERVICE/MainCollection('12345')/Other |
The problem happens when the OData handler class attempts to use the ~request_uri header value to determine the service to execute and is unable to because of of the %28%27 and %27%29 surrounding the parameter.
As a very temporary dirty solution to get it working so that I can continue with my development in the mean time, I put an enhancement at the top of the method IF_HTTP_EXTENSION~HANDLE_REQUEST in /IWCOR/CL_DS_HDLR_HTTP to replace the encoded URL values. As follows
DATA: lv_zrequest_line type string,
lv_zrequest_uri type string,
lv_zpath type string.
lv_zrequest_line = server->request->get_header_field( '~request_line' ).
lv_zrequest_uri = server->request->get_header_field( '~request_uri' ).
lv_zpath = server->request->get_header_field( '~path' ).
REPLACE ALL OCCURRENCES OF '%28' IN lv_zrequest_line WITH '('.
REPLACE ALL OCCURRENCES OF '%27' IN lv_zrequest_line WITH `'`.
REPLACE ALL OCCURRENCES OF '%29' IN lv_zrequest_line WITH ')'.
REPLACE ALL OCCURRENCES OF '%28' IN lv_zrequest_uri WITH '('.
REPLACE ALL OCCURRENCES OF '%27' IN lv_zrequest_uri WITH `'`.
REPLACE ALL OCCURRENCES OF '%29' IN lv_zrequest_uri WITH ')'.
REPLACE ALL OCCURRENCES OF '%28' IN lv_zpath WITH '('.
REPLACE ALL OCCURRENCES OF '%27' IN lv_zpath WITH `'`.
REPLACE ALL OCCURRENCES OF '%29' IN lv_zpath WITH ')'.
server->request->set_header_field( name = '~request_line' value = lv_zrequest_line ).
server->request->set_header_field( name = '~request_uri' value = lv_zrequest_uri ).
server->request->set_header_field( name = '~path' value = lv_zpath ).
However, as I cannot leave the above TEMPORARY solution in place, I was wondering if anyone could assist answering these questions:
1. Is this potentially a bug in SAP NW Gateway Core Framework? or....
2. Is this potentially a bug with how SUP/SMP passes in the URL to Gateway, since the same service works elsewhere via a browser and via the OData SDK for android.
3. Am I supposed to be setting up the URI template in the Mobile SDK differently, so that it passes the header values in correctly to Gateway?
Anyone else had this issue and managed to resolve it?
Thanks,
Brad