Apigee: Set use.proxy dynamically instead of hard-coded - service

We need to clarify if the use.proxy is true or false and this value should come dynamically via the properties file. Following two scenarios can happen:
If we send a request or a service callout to the real backend, we need use.proxy=true.
If we send a request or a service callout to the simulated backend (for continuous integration), we need use.proxy=false.
Unfortunately the simulation is an IP, which is not accessible via a proxy.
What we tried out:
<Property name="use.proxy">{_PROXY_CHOICE}</Property>
And in the properties-file the argument:
context.setVariable('_PROXY_CHOICE', '${proxy.choice}');
But nothing happened. Anyone any clues how to solve this issue?

I would have proxy to real backend configured in the properties file and have use.proxy set to true - so by default it keeps using real backend. And use.proxy to false in case of simulation in the proxy - so just play around with use.proxy based on the request - as i understand you can change this per request in proxy.

Related

Springdoc (Swagger) grouping configuration after proxy

I'm using newest springdoc library to create one common endpoint with all Swagger configurations in one place. There're a bunch of microservices deployed in Kubernetes, so having documentation in one place would be convenient. The easiest way to do that is by using sth like this (https://springdoc.org/faq.html#how-can-i-define-groups-using-applicationyml):
springdoc:
api-docs:
enabled: true
swagger-ui:
disable-swagger-default-url: true
urls:
- name: one-service
url: 'http://one.server/v3/api-docs'
- name: second-service
url: 'http://second.server/v3/api-docs'
and it works great, I can choose from list in upper right corner.
The problem is that it doesn't work through proxy. According to documentation I need to set some headers (https://springdoc.org/faq.html#how-can-i-deploy-springdoc-openapi-ui-behind-a-reverse-proxy) and it works for single service called directly. But when i try grouping described above, headers are not passed to one-service or second-service, and they generates documentation pointing to localhost.
I suspect I need to use grouping (https://springdoc.org/faq.html#how-can-i-define-multiple-openapi-definitions-in-one-spring-boot-project) but I miss good example, how to achive similar effect (grouping documentation from different microservices). Examples shows only one external address, or grouping local endpoints. I hope, that using this approach, I'll be able to pass headers.
The properties springdoc.swagger-ui.urls.*, are suitable to configure external (/v3/api-docs url), for example if you want to agreagte all the endpoints of other services, inside one single application.
It will not inherit the proxy configuration, but it will use servers urls defined in your: servers http://one.server/v3/api-docs and http://second.server/v3/api-docs.
You want to have a proxy in front of your service, it's up to your service to handle the correct server urls you want to expose.
If you want it work out of the box, you can use a solution that handles proxying and routing like spring-cloud-gateway

Office Online Server is taking long time to perform the auto-save operation

We integrated Office Online Server in our web application and in the WOPI web integration we are setting File URL properties such as FileUrl. This URL points to /wopi/files/{file_id}/contents link and internally, it will call the API once we start editing the document.
From this API, we are updating the file version but the issue is that after editing the WOPI document, the triggering of the API /wopi/files/{file_id}/contents is taking a long time and we are unable to find how it is getting triggered? Is there a way we can trigger this method directly?
So if I get it right it takes a long time BEFORE the /wopi/files/{file_id}/contents endpoint is hit.
In such a case, I'd recommend four things:
Run the WOPI host in a debug mode and trigger the endpoint from the OOS machine manually and see if there are any delays related to the network infrastructure.
Checking whether you set the WOPI host capabilities right in the CheckFileInfo. If you set the WOPI Client's expectations incorrectly, it may take time for it to figure out what's going on and potentially fall back to a different method.
Using the WOPI validator app
Checking the event viewer for any errors related to a specific Session ID and Correlation ID

Configure SAP Gateway service to ignore properties from payload that are not defined

The scenario is simple: I have a list of products and on frontend I create a property on the fly in the oData model ("EditMode"). I use this property only for frontend to enable/disable some input fields.
When I perform an update(POST) the gateway request faild (400-bad request) because "EditMode" is not defined on the Product entity.
How can I configure the gateway to ignore the properties that are not defined and take only what it needs from the payload?
It would be an overhead to delete this property from the oData model before sending the request, it will also affect the UI... :(
Thanks!
I think it's a very bad approach sending properties to the server that are not part of the data model. The OData 4.0 spec says (although SAP GW is still OData 2.0):
6.2 Payload Extensibility
OData supports extensibility in the payload, according to the specific
format. Regardless of the format, additional content MUST NOT be
present if it needs to be understood by the receiver in order to
correctly interpret the payload according to the specified
OData-Version header. Thus, clients and services MUST be prepared to
handle or safely ignore any content not specifically defined in the
version of the payload specified by the OData-Version header.
SAP GW "handles" unexpected properties by cancelling the request and sending a bad request response back. I believe there is no option to change this behavior and it would also kind of break "OData".
I assume you are using SAPUI5 on your frontend. There are many ways how you can achieve what you actually want - I'm very sure about this. But changing the "real" data, i.e. by adding an "additional" property was never needed in my cases. One way would be to bind the editable property of your controls to something like
"{view>/editmode}"
As you can guess this is a view model, also referred to as the "view model pattern". It only means you create a JSONModel in the controller (i.e. in the onInit) and and then call
this.getView().setModel(oModel, "view");
Whenever you want to disabled/enable editing to the set of controls just call this once:
var bEditable = ...; // true or false
//...
this.getView().getModel("view").setProperty("/editMode", bEditable);
Another option would be to have 2 different views/targets, one for editMode and one for display mode. If you want to follow the Fiori guides I think you should use this option. It's up to you...
Those options assume that you use exactly one flag to make "all" controls either editable or not.
If you you need some additional advice make sure to post some code to better illustrate your issue.

Test symfony restful api with phpunit and doctrine

I'm trying to pull-of some tests for my RESTful api functions.
For this I did the following:
Installed PHPUnit.
Created a new database for testing.
Created a new enviorment (test) and changed the doctrine config for it.
Created a test.
My problem is this:
When performing a request (somedomain.com/api/somemethod) -> the requested page doesn't know i'm performing a test on it -> so the data it uses is the production/development database and not the 'test' db i have created for the tests.
(the script using test db, the requested page uses normal configurations).
Is there a way to solve it without touching or modifying the API code/behavior?.
Thanks.
Since you said you're requesting somedomain.com I can only suspect you're firing requests over HTTP.
Symfony is made to be easily testable and you can perform functional test without ever making a real HTTP request. Instead, it will make a request object and tell it's kernel to handle it as if it were coming from a real client.
There is a chapter in symfony book on this: Functional tests
If you use method described there (using Symfony BrowserKit client and paths instead of complete urls), Symfony will have it's kernel booted in test environment and will handle request like that.
If, however, for any reason you are unable/don't want to do it that way, and want to fire real HTTP requests, I suggest you to make a file in web directory called app_test.php. In that file you should boot the kernel in test environment and make sure your tests are actually hitting that file (instead of app.php or app_dev.php). However, have in mind that this file will be publicly available and as so, it will cause a security hole so make sure to guard it somehow (check app_dev.php for hints). As an idea, you could require specific key to be provided in request header to allow it to pass on. Or if it will be tested from a single machine, you could also guard it by IP, or whatever works for your case.

Blackberry ksoap2 request issues

First time posting a question. I'm trying to call some SOAP webservices from inside a blackberry app using the ksoap2 library. I've successfully managed to get a response from the one service, which uses an HTTP url, but now that I'm trying to get response from a (different) HTTPS url, I've run up against a brick wall.
The response dump I'm getting has the following fault message:
"An error occurred while routing the message for element value : (country option I specified in my request). Keep-Alive and Close may not be set using this property. Parameter name: value."
The weird thing is that using Oxygen XML's SOAP tools with the XML request dump works just fine. Any ideas where to start looking? This has taken up a full day already.
Update:
Responding to your comment below - it turns out the double quoting is part of the SOAP spec. Some servers are more relaxed in their implementation, and will work without the quotes.
ksoap2 doesn't force the quotes onto your actions - you may want to patch your ksoap2 library to ensure the quotes are always there.
ymmv
Original:
I don't think this is a SOAP related problem, nor with BlackBerry.
I think the problem lies on the server side, since that error string is not a common error (just google it to see no hits on the whole internet other than this question).
Looks like this is a job for the network guy on the server side to tell you what he's seeing on his end.
Only other thing I can think of is to make the call using HTTP instead of HTTPS. You can then use some network sniffer to see what the difference between the messages is. Alternatively, install an SSL proxy with something like "Charles" and sniff the packets like that.