update rest

This commit is contained in:
Yoann
2024-04-01 22:59:01 +02:00
parent f130223c71
commit 967d271ee5
4 changed files with 18 additions and 14 deletions

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -1,3 +0,0 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}

View File

@@ -38,7 +38,6 @@
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet.api.version}</version>
<scope>provided</scope>
</dependency>
<!-- Jersey -->
@@ -97,6 +96,13 @@
<version>4.0.5</version>
</dependency>
<!-- Client -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>

View File

@@ -1,6 +1,7 @@
package test;
package client.test;
import fr.istic.servlet.HelloServlet.*;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
@@ -27,9 +28,17 @@ public class TestApi {
public static void main(String[] args) {
Client client = ClientBuilder.newClient();
SomeMessage serverResponse = client.target(URL).path("hello").path("Bob")
.request(MediaType.APPLICATION_JSON_TYPE).get(SomeMessage.class);
System.out.println(serverResponse.greetings + " " + serverResponse.name);
//Supprimez cette ligne quand vous ferez le client :
System.exit(0);
//Post a message :
ChatMessage m = new ChatMessage();
m.content="test";
m.content= "client/test";
Response response = client.target(URL).path("messages").request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(m, MediaType.APPLICATION_XML));
System.out.println("Response "+ response.getStatus());