Skip to content

Commit 6e2c428

Browse files
committed
Adding a simple sample to compare REST and WebSocket payloads
1 parent 5a8e87b commit 6e2c428

File tree

7 files changed

+79
-0
lines changed

7 files changed

+79
-0
lines changed

websocket/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
<module>websocket-client-programmatic-encoders</module>
4545
<module>whiteboard</module>
4646
<module>endpoint-singleton</module>
47+
<module>websocket-vs-rest-payload</module>
4748
</modules>
4849
</project>
5.69 KB
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>org.javaee7.websocket</groupId>
6+
<artifactId>websocket-samples</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
11+
<artifactId>websocket-vs-rest-payload</artifactId>
12+
<packaging>war</packaging>
13+
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.javaee7.websocket.websocket.vs.rest.payload;
2+
3+
import javax.ws.rs.core.Application;
4+
5+
/**
6+
* @author Arun Gupta
7+
*/
8+
@javax.ws.rs.ApplicationPath("webresources")
9+
public class ApplicationConfig extends Application {
10+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.javaee7.websocket.websocket.vs.rest.payload;
2+
3+
import javax.ws.rs.Consumes;
4+
import javax.ws.rs.POST;
5+
import javax.ws.rs.Path;
6+
import javax.ws.rs.Produces;
7+
8+
/**
9+
* REST Web Service
10+
*
11+
* @author Arun Gupta
12+
*/
13+
@Path("rest")
14+
public class MyRestEndpoint {
15+
16+
@POST
17+
@Consumes("text/plain")
18+
@Produces("text/plain")
19+
public String getXml(String payload) {
20+
return payload;
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.javaee7.websocket.websocket.vs.rest.payload;
2+
3+
import javax.websocket.OnMessage;
4+
import javax.websocket.server.ServerEndpoint;
5+
6+
/**
7+
* @author Arun Gupta
8+
*/
9+
@ServerEndpoint("/websocket")
10+
public class MyWebSocketEndpoint {
11+
12+
@OnMessage
13+
public String echoText(String text) {
14+
return text;
15+
}
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<%@page contentType="text/html" pageEncoding="UTF-8"%>
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6+
<title>REST vs WebSocket - Payload</title>
7+
8+
</head>
9+
<body>
10+
<link rel="stylesheet" href="stylesheet.css" type="text/css">
11+
<h1>REST vs WebSocket - Payload</h1>
12+
13+
Use Adavanced REST Client extension to send requests.<br>
14+
Capture REST/HTTP headers using the extension.<br>
15+
Capture WebSocket headers using Wireshark.
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)