63
Views
12
Comments
Service Action not able to read/write additional header from/to request/response
Application Type
Service
Service Studio Version
11.54.56 (Build 63232)
Platform Version
11.24.0 (Build 41209)

From reactive app overriding xmlhttprequest.prototype.send Im trying to send an additional header to outsystem Service/Server action.

From Server action im able to read the additional header which I sent, but in case of Service action not able to read the header. 

And whem Im writing additional header from Service/Server action, in Service  action not returning the  additional  header in http response.

Any solution to read/write the additional header from Service Action.??


Capture.GIF
UserImage.jpg
Alexandre Yip

Hi Sadikul Sayed, 

Did you use that code in service action?  in the service action use the server action that you have created previously it should work. 

Hope that it helps you 

UserImage.jpg
Sadikul Sayed

Hi Alexandre, in both service/server action I have used the same code. 

Using HTTPRequestHandler.GetRequestContent I tried to read request context, I see a difference btn service and server action.

From the same application while calling a server action requested headers and body are same   inside server action, but in case of service action its getting changed. Here is a sample


UserImage.jpg
Alexandre Yip

Hi Sadikul Sayed, 

my suggestion is to use the server action with the code directly in the service action. 

Can you try it? 

Regards 

UserImage.jpg
Sadikul Sayed

Hi Alexandre, 

Im have tried the same, but no luck yet. 

And my analysis is, in ousystems some kind of gateway has been implemented while calling a service action. Once ousystems receive a service action, the gateway reroute the request to another service.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

What are you trying to achieve with sending an additional header to a service action?

-- Daniel

UserImage.jpg
Sadikul Sayed

Hi Daniel,

What I trying to achive, adding additional Authorization checks in Server/Service Action. I have implemented SSO in Outsystems and for Authorization im not using anything providev by  Outsystems. After authentication I will get the access token, and that token I want to pass in all the Server/Service action, and inside the Server/Service action I will add my Authorization check logic. To achive this I want to pass the access token to all the Server/Service action by overriding xmlhttprequest.prototype.send.

Note: From Reactive app im calling Server/Service action, not rest api.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Alright, interesting, please share if you get this working.

One question, why are you not using the normal Role-Based-Access validation in actions?


UserImage.jpg
Sadikul Sayed


Hi Daniel, 

Im not using Role-Based-Access validation, permission/roles is managed by a saperate service, and after authentication I have a access token which contains some claims for permission/roles. Outsystems dont have any information about those permission/roles and dont have access to the database where its getting managed.

UserImage.jpg
Alexandre Yip

Hi Sadikul Sayed, 

Just an idea, in the service action if you output the x-correlation-id value it would be suitable for you? 


Regards 

UserImage.jpg
Sadikul Sayed

Hi Alexandre,

In Service Action nither I can read additional header which Im sending, nor I can write additional header into my response, and that header is not coming to my response.


But in Server both are working fine.

UserImage.jpg
Alexandre Yip

Hi Sadikul Sayed, 

I probably was not clear, first your javascript could retrieve as output the x-correlation-id value which I believe is what you want to to check after. 

Secondly in the service action add as well an output parameter and assign the javascript output value. 

Regards 

UserImage.jpg
Sadikul Sayed

Hi Alexandre,

Here is what im trying to do

Step 1: Send an additional header, lets say x-correlation-id from using javascript to all the service action

Step 2: Read the header i.e x-correlation-id  from Service action. (which is not working)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.