Last modified by Martijn Woudstra on 2023/04/13 15:33

From version 77.1
edited by Martijn Woudstra
on 2022/09/01 08:27
Change comment: There is no comment for this version
To version 78.1
edited by Martijn Woudstra
on 2023/04/13 15:33
Change comment: Imported from XAR

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,8 @@
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 +
2 2  In this microlearning, we will discuss how you can manually host a REST web service outside the API management layer of eMagiz.
3 3  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.
4 4  
... ... @@ -97,7 +97,7 @@
97 97  
98 98  The only thing left to do is to save this configuration. This concludes the first steps for successfully making endpoints available.
99 99  
100 -Based on the above configuration the endpoint will now look as follows: http://localhost:port/microlearning/apigateway/\*
104 +Based on the above configuration the endpoint will now look as follows: {{code}}http://localhost:port/microlearning/apigateway/{{/code}}
101 101  
102 102  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.
103 103  
... ... @@ -129,7 +129,7 @@
129 129  
130 130  [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--http-inbound-gateway-parameters.png]]
131 131  
132 -Based on the above configuration the endpoint will now look as follows: http://localhost:port/microlearning/apigateway/demo
136 +Based on the above configuration the endpoint will now look as follows: {{code}}http://localhost:port/microlearning/apigateway/demo{{/code}}
133 133  
134 134  === 3.4 Error Handling ===
135 135  
... ... @@ -136,9 +136,9 @@
136 136  **Returning a 401**
137 137  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:
138 138  
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}')
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}}
140 140  * 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
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" }]}'.
145 +* Add a standard transformer to set a default message that can be given back to the client. An example would be {{code language="xml"}}{ "errors": [{ "internalMessage": "Unauthorized" }]}{{/code}}.
142 142  
143 143  [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-401.png]]
144 144  
... ... @@ -150,15 +150,15 @@
150 150  
151 151  * Add a separate HTTP inbound channel adapter that resolves to /\* (this catches everything that cannot be resolved by any other HTTP inbound channel adapter)
152 152  * Set a standard header enricher and add a header called http_statusCode with a value 404
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" }]}.
157 +* Add a standard transformer to set a default message that can be given back to the client. An example would be {{code language="xml"}}{ "errors": [{ "internalMessage": "Het aangeroepen endpoint is niet gevonden" }]}{{/code}}.
154 154  
155 155  [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-404.png]]
156 156  
157 157  **Returning a 500**
158 158  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.
159 -* 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
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 enricher
160 160  * Set a standard header enricher and add a header called http_statusCode with a value of 500
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" }]}.
165 +* Add a standard transformer to set a default message that can be given back to the client. An example would be {{code language="xml"}}{ "errors": [{ "internalMessage": "Een technische error heeft plaatsgevonden in de integratie" }]}{{/code}}.
162 162  
163 163  [[image:Main.Images.Microlearning.WebHome@intermediate-rest-webservice-connectivity-configuration--service-500.png]]
164 164  
... ... @@ -165,7 +165,7 @@
165 165  == 4. Assignment ==
166 166  
167 167  Navigate to a flow within your (Academy) project and configure a REST Webservice that eMagiz will host without worrying about error handling and authentication.
168 -In this REST Webservice expose the POST operation on the following endpoint: http://localhost:port/microlearning/apigateway/demo
172 +In this REST Webservice expose the POST operation on the following endpoint: {{code}}http://localhost:port/microlearning/apigateway/demo{{/code}}
169 169  This assignment can be completed with the help of the (Academy) project that you have created/used in the previous assignment.
170 170  
171 171  == 5. Key takeaways ==