cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PO REST receiver {http_result}

holakac
Explorer
6,593

Hello,

we're on SAP PO 7.5 SP14, and struggle with REST receiver adapter. We've a REST service, which returns HTTP 302 with location in header, AND a payload with some additional data. Currently the receiver is setup with module parameters:

ProceedRedirects = false

useResponseErrorMessage = true

setAppErrorOnCustomMessage = true

Result handler is set for Exception - custom result, message content is only {http_result}.

However, the response is always empty. I've browsed through notes 2273265, 2238546 and 2223623 and I think my setup should be OK, but it's not working as expected.

Any suggestion on howto to achieve to NOT follow redirect and send the payload to sender ? When I try in postman/soap ui everything works.

EDIT: I've tried to generate some other error than HTTP 302 - http_result is filled properly (I've tried 403), but whenever I trigger 302, it's empty.

Also in my original post I mentioned incorrect module parameter - setAppErrorOnCustomMessage is the one that should allow me to use http_result during custom error handling, but's not working as expected.

This:

Produces proper output:

{ "status": { "statusCode": "ERROR_VALUE_INVALID", "code": 8062, "codeLiteral": "INVALID_AUTH_FOR_THIS_ORDER", "statusDesc": "Permission denied for given action" } }

While 302:

Produces empty response. But in Postman there's a payload!

Settings:

Accepted Solutions (1)

Accepted Solutions (1)

holakac
Explorer
0 Kudos

The problem was finally solved with note 2837075 (https://launchpad.support.sap.com/#/notes/2837075)

Answers (3)

Answers (3)

holakac
Explorer

So after some time we've found the problem (after decompilation of com.sap.aii.adapter.rest.ejb.jar and looking to the code) - we think the problem is in REST adapter, where the ProceedRedirects = false throws an exception, and during exception, variables http* are not filled.

5.jpg

So we've raised an incident to SAP.

However, since we need a solution, we've developed a custom REST adapter, which was basically a copy of the decompiled .jar, and fixed few lines of code so that the ProceedRedirects do not throw exception.

JaySchwendemann
Active Contributor
0 Kudos

Some thoughts / questions on that, because I haven't really got your requirement.

  1. Do you own the REST service in question? If not, why would you want to get hold of the redirect payload? Wouldn't it be (in case of POST) wiser, to follow that redirect and return the then hopefully more meaningful payload?
  2. When looking at https://launchpad.support.sap.com/#/notes/2238546 SAP seems to have created that switch "ProceedRedirects" with load balancers in mind as use case. With that in mind it might not make much sense (for SAP) to return a payload when you specifically opted not to follow the redirect.

Cheers

Jens

holakac
Explorer
0 Kudos

Ad 1) REST service returns HTTP 302 and location in header + Payload, that has some data, that are NOT in the location where it's redirected, therefore, we need to process this payload. Also, the location have to be returned to sender (which is an application that can't consume the REST service directly due to security reasons)

Ad 2) I can't comment whether it makes sense or not, but according to RFC 7231 HTTP 302 response can contain payload, and with current options in SAP REST adapter, this payload is not accessible. And there are many services, that works like this.

JaySchwendemann
Active Contributor
0 Kudos

Also I would like to suggest to have a look at my all time favorite tool XPI Inspector (anybody getting bored by this boilerplate text of mine already?)

https://launchpad.support.sap.com/#/notes/1514898

I find it an invaluable asset when it comes to narrowing down issues in communication channels / modules / mapping or even other areas like SSL.

Cheers

Jens

holakac
Explorer
0 Kudos

I do know XPI inspector, however I don't see any added value in my case - data are present in the message, but are not present in supplied variables.

JaySchwendemann
Active Contributor
0 Kudos

Oh but you would have seen some trace entries eventually, e.g. "Redirect response received, but your option is not to process redirects! Check note 2238546!

🙂

vicky20691
Active Contributor
0 Kudos

Hi,

Please add another Result Handler . Every status code is not exception.

holakac
Explorer
0 Kudos

Hello, thanks for reply, I've tried, but it doesn't work. Current exception handling setup:

It seems that whenever an expcetion is triggered, payload is lost. But that should be avoided by the module parameter setAppErrorOnCustomMessage 😕