You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: devon4j-http-rest-client/index.asciidoc
+64-31Lines changed: 64 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,25 +35,57 @@ For more details on devon4j Service Client https://devonfw.com/website/pages/doc
35
35
36
36
## Create the devon4j REST SERVER
37
37
As explained in REST document, With JAX-RS it is important to make sure that each service method is annotated with the proper HTTP annotation(@GET, @POST, etc).
38
-
Let's create devon4j server. You have to modify BaseWebSecurityConfig file to allow application for basic authentication.
39
-
In below example you will create VisitormanagementRestService and it's implementation i.e. VisitormanagementRestServiceImpl using JAX-RS standard.
Here , you can see "VisitormanagementRestServiceImpl.java" is annotated with @Named to make it a spring-bean. To get return response to client "returnResponseToClient()" can be accessed via HTTP GET under the URL path "/visitormanagement/v1/clientrequest". It will return its result (String) as JSON (see @Produces in VisitormanagementRestService).
51
72
====
52
73
53
74
75
+
Now, you will configure port in application properties.
As you can see synchronous invocation of a service is very simple and type-safe. The actual call of showResponse will technically call the remote service(i.e. VisitormanagementRestService) over the wire ( via HTTP) including marshaling the arguments (converting String to JSON) and un-marshalling the result (e.g. converting the received JSON to String).
105
153
Here in Devon4jRestClientImpl, there is a method "callSynchronous" which will call the VisitormanagementRestService and return the object of VisitormanagementRestService to visitormanagementRestService.
106
154
With visitormanagementRestService, it is calling the method "returnResponseToClient(String)" of server.
107
155
The response from server will be stored in "resultFromAPICall" as the return type of result is String.
108
-
109
156
After getting response, you can handle the response further in your implementation. Here, you can see that response is getting handled in "showResponse" method.
110
157
====
111
158
@@ -114,59 +161,45 @@ After getting response, you can handle the response further in your implementati
114
161
An application needs to be configurable in order to allow internal setup but also to allow externalized configuration of a deployed package (e.g. integration into runtime environment).
115
162
Now, You need to modify the content of existing properties files and add configuration for Server.
**service.client.default.url** :- It is used to set the default url of server and it is added for service discovery.
171
+
124
172
**service.client.app.httprestserver.url** :- This property provide base url of REST in your application. It follows format such as "service.client.app.«application».url". Here, «application» refers to the technical name of the application providing the service.
125
173
126
174
## Timeouts
127
175
**service.client.default.timeout.connection** :- It is used to set the default timeout for particular connection.
176
+
128
177
**service.client.default.timeout.response** :- It is used to set the default timeout for particular response.
129
178
130
179
## Headers
131
180
**service.client.app.httprestserver.auth** :- It is used for customization of Service Header. Here it is used for basic authentication.
132
181
133
182
## Authentication
134
-
**service.client.app.httprestserver.user.login** :- It is used to set username of server for authentication
183
+
**service.client.app.httprestserver.user.login** :- It is used to set username of server for authentication.
184
+
135
185
**service.client.app.httprestserver.user.password** :- It is used to set password.
136
-
Now, after configuration you have to build and then start the client application.
137
186
====
138
187
139
-
====
140
-
You have successfully built the devon4j rest client.
141
-
Let's build and start the service client application.
188
+
189
+
Now, Let's build and start the service client application.
142
190
This might take some time for application to start.
143
191
[step]
144
-
== Build and Start devon4j REST Client
192
+
== Build devon4j CXF REST Client
145
193
--
146
194
buildJava("httprestclient", false)
147
195
--
148
196
149
-
* Once, application builds successfully. Open new terminal by clicking "+" and wait for it to load.
150
-
* Now, Copy and execute below command to navigate into client server.
0 commit comments