on 05-15-2014 9:18 AM
Hi,
I'm the beginner in SAP NetWeaver Gateway. Using Service Builder I created CRUD OData web service and implemented CRUD operations in Data Provider Class. Data Provider Class has methods like MYENTITY_GET_ENTITYSET, MYENTITY_GET_ENTITY, MYENTITY_CREATE_ENTITY, MYENTITY_UPDATE_ENTITY. How can I get HTTP headers from the methods of this Data Provider Class?
You can do so by using the following code in DPC
Data : Lo_facade type ref to /IWBEP/IF_MGW_DP_INT_FACADE.
lo_facade ?= /iwbep/if_mgw_conv_srv_runtime~get_dp_facade( ).
lt_client_headers = lo_facade->get_request_header( ).
Regards,
Atanu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Yauhen,
Could you please explain your question more in detail ? Do you want information regarding what headers you need to pass for Create , Update , Delete & Get operations ? is this what you are expecting ?
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Yauhen,
I do not see any way you can access Header Values in your DPC methods.
I am very much doubt full if you can access Yauhen.
You can set authorizations headers with user and password while firing service for authentication purpose to check if user has access to the system which we are trying to hit.
Otherwise why would anybody need that check apart from the above i mentioned ?
Its good if you can tell what is your scenario and why you would do that check.
Regards,
Ashwin
Hello Ashwin,
I want to get access to the service for registered users and to retrieve different data from service for each registered user. So I have to check user's credentials and return information depending on username. I will send Authorization header with encoded username and password values to the service from my web app.
Maybe, this way is wrong. I'm a newbie and I would be happy to know best practices for such problem.
Best regards,
Yauhen
Hello Yauhen,
As far as i know you cannot read the UserName and Password that you pass in Authentication Header for a particular user inside DPC and return information based on it . Because this Authentication Header is used to check if user has access to the system from which he/she would like to get data.
But your scenario is different from the above is what i could understand.
You have few registered users and would like to return info based on User and Password.
Is it really necessary to pass Password along with User in your scenario ? only passing user will not do ? Since Users are already registered , you just have to get users and pass info for that particular user.
In my opinion Passing Password along with User in URL is not correct.
Suggestion would be pass User and retrieve info.
If at all you are sending one user at a time to validate and return single entry, then you can implement Get_Entity ( Read ) . Pass User Name as Key and get info.
If you have many users to validate at a time and return single entry for each of them, then u can operate on BATCH mode for Read Operation.
Regards,
Ashwin
Hello Ashwin,
Probably, the description of my problem was not clear. I have a table of users and a table of products. Users have username and password. Each user has a list of his products.
A user can get the list of own products and edit it. But user cannot get and edit the list of products of another user. So I have to pass username and password with each request, otherwise user can get another's products only with foreign username.
Best regards,
Yauhen
Hello Yauhen,
Please follow the code to get Headers like how Atanu has suggested and
implement Get_EntitySet and get all the products for that particular User.
Now the next question is how will you send table of users and get corresponding result ?
Since your approach is to send user name and password in the headers and use it to get list of products for that particular user,
even if you operate on BATCH for Query operation how will you send credentials of all those table of users in a single header ? You cannot set headers for all those users with their respective User Name and password correct ? Because Gateway does not support that.
Now its up to you how you would like to model your service and fire it
Regards,
Ashwin
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.