on 05-27-2013 10:30 PM
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
Hi Brad,
I have a similar problem.
This URL works:
http://<port>:8000/sap/opu/odata/sap/LLG_SAP_PM_INTEGRATION/mobile_orders('000000819740')
But the following fails:
Were you able to fix your issue? If so, how have you done it?
Many thanks for your help.
Regards,
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andreas,
The below code is what I implemented in an enhancement implementation in class /IWCOR/CL_DS_HDLR_HTTP at the beginning of method IF_HTTP_EXTENSION~HANDLE_REQUEST.
Its not ideal and is a dirty fix, but it did the job. In the mean time, I have moved away from the MBO / OData approach and taken a different route.
To me it seems like there is a bug in SAP or SUP. and may be worth logging an OSS message for it.
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 ).
Hope this helps you a bit.
Cheers,
Brad
Hi Brad,
many thanks for your quick reply.
I am not sure whether my code base is using that interface method. I could not find it.
My Gateway system is based on:
SAP_BASIS 702 0009
and all GW add-ons are on SP-Level 0006
I assume that I am not allowed to follow your approach.
My solution just depends on Gateway and not on SUP.
Regards,
Andreas
Hi Andreas,
It was Gateway which I made this change in, same version as yours. go to SE24 and display the class /IWCOR/CL_DS_HDLR_HTTP in there. It should be there as its the core http handler for the framework.
In my case I was using SUP/SMP. But I would imagine this could possibly occur without it as well.
Cheers,
Brad
Hi Brad,
you are right. This class exist on my Gateway System. I do the implementation on the ERP system.
It's look like that this method is not causing my problem. I am trying this URL
http://<host>:8000/sap/opu/odata/sap/LLG_SAP_PM_INTEGRATION/mobile_orders%28%27000000819740%27%29
And the debugger shows it correctly, like
http://<port>:8000/sap/opu/odata/sap/LLG_SAP_PM_INTEGRATION/mobile_orders('000000819740')
Many thanks for your help!
Cheers,
Andreas
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.