Changes for page Configuration REST web service
Last modified by Martijn Woudstra on 2023/04/13 15:33
To version 77.1
edited by Martijn Woudstra
on 2022/09/01 08:27
on 2022/09/01 08:27
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,8 +1,4 @@ 1 1 {{container}}{{container layoutStyle="columns"}}((( 2 -{{error}} 3 -Note that the functionality mentioned in this microlearning will become obsolete when migrating to the 3rd generation runtime. 4 -{{/error}} 5 - 6 6 In this microlearning, we will discuss how you can manually host a REST web service outside the API management layer of eMagiz. 7 7 The main idea of hosting a web service, whether it be SOAP/XML or REST/JSON (or any other combination) is that the process you are supporting wants to be informed in real-time or wants to execute actions in real-time without any support from the integration. In other words, you want the application to push the requests to eMagiz instead of eMagiz having to pull the data out of an application. 8 8 ... ... @@ -101,7 +101,7 @@ 101 101 102 102 The only thing left to do is to save this configuration. This concludes the first steps for successfully making endpoints available. 103 103 104 -Based on the above configuration the endpoint will now look as follows: {{code}}http://localhost:port/microlearning/apigateway/{{/code}}100 +Based on the above configuration the endpoint will now look as follows: http://localhost:port/microlearning/apigateway/\* 105 105 106 106 In the next part of this microlearning, we will explain which steps you need to take per operation that you want to expose to the outside world. 107 107 ... ... @@ -133,7 +133,7 @@ 133 133 134 134 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--http-inbound-gateway-parameters.png]] 135 135 136 -Based on the above configuration the endpoint will now look as follows: {{code}}http://localhost:port/microlearning/apigateway/demo{{/code}}132 +Based on the above configuration the endpoint will now look as follows: http://localhost:port/microlearning/apigateway/demo 137 137 138 138 === 3.4 Error Handling === 139 139 ... ... @@ -140,9 +140,9 @@ 140 140 **Returning a 401** 141 141 In case you secure the web service with the help of an ApiKey you can validate whether what the client sends to the web service for authentication is indeed a correct ApiKey. This can be done via the following steps: 142 142 143 -* Place a standard filter in your entry to validate if the ApiKey provided by the client is valid. This can be done via a SpEL expression comparable to the following SpEL expression {{code language="spel"}}headers['Authorization'] == '${authentication.inbound.api-key}'{{/code}}139 +* Place a standard filter in your entry to validate if the ApiKey provided by the client is valid. This can be done via a SpEL expression comparable to the following (headers['Authorization'] == '${authentication.inbound.api-key}') 144 144 * In cases where the client is not authorized lead the message back to a standard header enricher. In this standard header, enricher add a header called http_statusCode with a value of 401 145 -* Add a standard transformer to set a default message that can be given back to the client. An example would be { {codelanguage="xml"}}{ "errors": [{ "internalMessage": "Unauthorized" }]}{{/code}}.141 +* Add a standard transformer to set a default message that can be given back to the client. An example would be '{ "errors": [{ "internalMessage": "Unauthorized" }]}'. 146 146 147 147 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-401.png]] 148 148 ... ... @@ -154,15 +154,15 @@ 154 154 155 155 * Add a separate HTTP inbound channel adapter that resolves to /\* (this catches everything that cannot be resolved by any other HTTP inbound channel adapter) 156 156 * Set a standard header enricher and add a header called http_statusCode with a value 404 157 -* Add a standard transformer to set a default message that can be given back to the client. An example would be { {codelanguage="xml"}}{ "errors": [{ "internalMessage": "Het aangeroepen endpoint is niet gevonden" }]}{{/code}}.153 +* Add a standard transformer to set a default message that can be given back to the client. An example would be '{ "errors": [{ "internalMessage": "Het aangeroepen endpoint is niet gevonden" }]}’. 158 158 159 159 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-404.png]] 160 160 161 161 **Returning a 500** 162 162 eMagiz will give back a 500 by default if the flow results in an unresolvable error. To counteract this for most scenarios the error handling in eMagiz for synchronous flows has changed in such a way that the message or error will be given back to the client. To specify the HTTP code and body of the response you can follow these steps. 163 -* Use the standard filter eMagiz gives you in a synchronous flow (with the SpEL expression {{code language="spel"}}headers['emagiz_error_isErrorMessage']!=true{{/code}}) and make sure that instead of throwing a default error the error channel leads to a standard header enricher159 +* Use the standard filter eMagiz gives you in a synchronous flow (with the SpEL expression headers['emagiz_error_isErrorMessage']!=true) and make sure that instead of throwing a default error the error channel leads to a standard header enricher 164 164 * Set a standard header enricher and add a header called http_statusCode with a value of 500 165 -* Add a standard transformer to set a default message that can be given back to the client. An example would be { {codelanguage="xml"}}{ "errors": [{ "internalMessage": "Een technische error heeft plaatsgevonden in de integratie" }]}{{/code}}.161 +* Add a standard transformer to set a default message that can be given back to the client. An example would be '{ "errors": [{ "internalMessage": "Een technische error heeft plaatsgevonden in de integratie" }]}’. 166 166 167 167 [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-500.png]] 168 168 ... ... @@ -169,7 +169,7 @@ 169 169 == 4. Assignment == 170 170 171 171 Navigate to a flow within your (Academy) project and configure a REST Webservice that eMagiz will host without worrying about error handling and authentication. 172 -In this REST Webservice expose the POST operation on the following endpoint: {{code}}http://localhost:port/microlearning/apigateway/demo{{/code}}168 +In this REST Webservice expose the POST operation on the following endpoint: http://localhost:port/microlearning/apigateway/demo 173 173 This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment. 174 174 175 175 == 5. Key takeaways ==