ajout TP3
This commit is contained in:
parent
d78421a24a
commit
c9d7acaedc
52
TP3/.vscode/settings.json
vendored
Normal file
52
TP3/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar",
|
||||
"apache-tomcat-ws/lib/activation-1.1.jar",
|
||||
"apache-tomcat-ws/lib/annotations-api.jar",
|
||||
"apache-tomcat-ws/lib/catalina.jar",
|
||||
"apache-tomcat-ws/lib/catalina-ant.jar",
|
||||
"apache-tomcat-ws/lib/catalina-ha.jar",
|
||||
"apache-tomcat-ws/lib/catalina-storeconfig.jar",
|
||||
"apache-tomcat-ws/lib/catalina-tribes.jar",
|
||||
"apache-tomcat-ws/lib/commons-codec-1.6.jar",
|
||||
"apache-tomcat-ws/lib/commons-io-2.1.jar",
|
||||
"apache-tomcat-ws/lib/commons-logging-1.1.1.jar",
|
||||
"apache-tomcat-ws/lib/ecj-4.6.3.jar",
|
||||
"apache-tomcat-ws/lib/el-api.jar",
|
||||
"apache-tomcat-ws/lib/httpclient-4.2.6.jar",
|
||||
"apache-tomcat-ws/lib/httpcore-4.2.5.jar",
|
||||
"apache-tomcat-ws/lib/jackson-core-asl-1.9.12.jar",
|
||||
"apache-tomcat-ws/lib/jackson-jaxrs-1.9.12.jar",
|
||||
"apache-tomcat-ws/lib/jackson-mapper-asl-1.9.12.jar",
|
||||
"apache-tomcat-ws/lib/jackson-xc-1.9.12.jar",
|
||||
"apache-tomcat-ws/lib/jasper.jar",
|
||||
"apache-tomcat-ws/lib/jasper-el.jar",
|
||||
"apache-tomcat-ws/lib/jaspic-api.jar",
|
||||
"apache-tomcat-ws/lib/jaxrs-api-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/jboss-annotations-api_1.1_spec-1.0.1.Final.jar",
|
||||
"apache-tomcat-ws/lib/jcip-annotations-1.0.jar",
|
||||
"apache-tomcat-ws/lib/jsp-api.jar",
|
||||
"apache-tomcat-ws/lib/resteasy-client-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/resteasy-jackson-provider-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/resteasy-jaxb-provider-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/resteasy-jaxrs-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/resteasy-servlet-initializer-3.0.9.Final.jar",
|
||||
"apache-tomcat-ws/lib/servlet-api.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-api.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-coyote.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-dbcp.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-de.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-es.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-fr.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-ja.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-ko.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-ru.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-i18n-zh-CN.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-jdbc.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-jni.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-util.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-util-scan.jar",
|
||||
"apache-tomcat-ws/lib/tomcat-websocket.jar",
|
||||
"apache-tomcat-ws/lib/websocket-api.jar"
|
||||
]
|
||||
}
|
46
TP3/index.html
Normal file
46
TP3/index.html
Normal file
|
@ -0,0 +1,46 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("#BTVal").click(function() {
|
||||
jQuery.ajax({
|
||||
url: "http://localhost:8080/marks/rest/getmark",
|
||||
type: "GET",
|
||||
data: "firstname="+$("#FirstName").val()+"&lastname="+$("#LastName").val()+"&lecture="+$("#Lecture").val(),
|
||||
success: function (response) {
|
||||
$("#Result").empty();
|
||||
$("#Result").append(response);},
|
||||
error: function (res, status, error) {
|
||||
$("#Result").empty();
|
||||
$("#Result").append(error);}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form id="FormAddPerson">
|
||||
First Name: <input type="text" id="FirstName"><br>
|
||||
Last Name: <input type="text" id="LastName"><br>
|
||||
Lecture: <input type="text" id="Lecture"><br>
|
||||
<br>
|
||||
<input type="button" id="BTVal" value="OK">
|
||||
</form>
|
||||
|
||||
<br>
|
||||
|
||||
<div id="Result">
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
BIN
TP3/rappel-ws.odp
Normal file
BIN
TP3/rappel-ws.odp
Normal file
Binary file not shown.
BIN
TP3/rappel-ws.pdf
Normal file
BIN
TP3/rappel-ws.pdf
Normal file
Binary file not shown.
67
TP3/server-config.wsdd
Normal file
67
TP3/server-config.wsdd
Normal file
|
@ -0,0 +1,67 @@
|
|||
<ns1:deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java" xmlns:ns1="http://xml.apache.org/axis/wsdd/">
|
||||
<ns1:globalConfiguration>
|
||||
<ns1:parameter name="sendMultiRefs" value="true"/>
|
||||
<ns1:parameter name="disablePrettyXML" value="true"/>
|
||||
<ns1:parameter name="adminPassword" value="admin"/>
|
||||
<ns1:parameter name="attachments.Directory" value="/home/hagimont/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/zedu-soap/WEB-INF/attachments"/>
|
||||
<ns1:parameter name="dotNetSoapEncFix" value="true"/>
|
||||
<ns1:parameter name="enableNamespacePrefixOptimization" value="false"/>
|
||||
<ns1:parameter name="sendXMLDeclaration" value="true"/>
|
||||
<ns1:parameter name="sendXsiTypes" value="true"/>
|
||||
<ns1:parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl"/>
|
||||
<ns1:requestFlow>
|
||||
<ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
|
||||
<ns1:parameter name="scope" value="session"/>
|
||||
</ns1:handler>
|
||||
<ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
|
||||
<ns1:parameter name="scope" value="request"/>
|
||||
<ns1:parameter name="extension" value=".jwr"/>
|
||||
</ns1:handler>
|
||||
</ns1:requestFlow>
|
||||
</ns1:globalConfiguration>
|
||||
<ns1:handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
|
||||
<ns1:handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenticationHandler"/>
|
||||
<ns1:handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder"/>
|
||||
<ns1:service name="AdminService" provider="java:MSG">
|
||||
<ns1:parameter name="allowedMethods" value="AdminService"/>
|
||||
<ns1:parameter name="enableRemoteAdmin" value="false"/>
|
||||
<ns1:parameter name="className" value="org.apache.axis.utils.Admin"/>
|
||||
<ns1:namespace>http://xml.apache.org/axis/wsdd/</ns1:namespace>
|
||||
</ns1:service>
|
||||
<ns1:service name="Version" provider="java:RPC">
|
||||
<ns1:parameter name="allowedMethods" value="getVersion"/>
|
||||
<ns1:parameter name="className" value="org.apache.axis.Version"/>
|
||||
</ns1:service>
|
||||
<ns1:service name="Mark" provider="java:RPC" style="wrapped" use="literal">
|
||||
<ns2:operation name="getMark" qname="ns1:getMark" returnQName="ns1:getMarkReturn" returnType="xsd:string" soapAction="" xmlns:ns1="http://pack" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/axis/wsdd/">
|
||||
<ns2:parameter qname="ns1:firstname" type="xsd:string"/>
|
||||
<ns2:parameter qname="ns1:lastname" type="xsd:string"/>
|
||||
<ns2:parameter qname="ns1:lecture" type="xsd:string"/>
|
||||
</ns2:operation>
|
||||
<ns1:parameter name="allowedMethods" value="getMark"/>
|
||||
<ns1:parameter name="typeMappingVersion" value="1.2"/>
|
||||
<ns1:parameter name="wsdlPortType" value="Mark"/>
|
||||
<ns1:parameter name="className" value="pack.Mark"/>
|
||||
<ns1:parameter name="wsdlServicePort" value="Mark"/>
|
||||
<ns1:parameter name="schemaQualified" value="http://pack"/>
|
||||
<ns1:parameter name="wsdlTargetNamespace" value="http://pack"/>
|
||||
<ns1:parameter name="wsdlServiceElement" value="MarkService"/>
|
||||
</ns1:service>
|
||||
<ns1:transport name="http">
|
||||
<ns1:requestFlow>
|
||||
<ns1:handler type="URLMapper"/>
|
||||
<ns1:handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
|
||||
</ns1:requestFlow>
|
||||
<ns1:parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler"/>
|
||||
<ns1:parameter name="qs:wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
|
||||
<ns1:parameter name="qs.list" value="org.apache.axis.transport.http.QSListHandler"/>
|
||||
<ns1:parameter name="qs.method" value="org.apache.axis.transport.http.QSMethodHandler"/>
|
||||
<ns1:parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler"/>
|
||||
<ns1:parameter name="qs.wsdl" value="org.apache.axis.transport.http.QSWSDLHandler"/>
|
||||
</ns1:transport>
|
||||
<ns1:transport name="local">
|
||||
<ns1:responseFlow>
|
||||
<ns1:handler type="LocalResponder"/>
|
||||
</ns1:responseFlow>
|
||||
</ns1:transport>
|
||||
</ns1:deployment>
|
3
TP3/students-server/WebContent/META-INF/MANIFEST.MF
Normal file
3
TP3/students-server/WebContent/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,3 @@
|
|||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
18
TP3/students-server/WebContent/WEB-INF/web.xml
Normal file
18
TP3/students-server/WebContent/WEB-INF/web.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
|
||||
<display-name>essai-server</display-name>
|
||||
<servlet>
|
||||
<servlet-name>resteasy-servlet</servlet-name>
|
||||
<servlet-class>
|
||||
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
|
||||
</servlet-class>
|
||||
<init-param>
|
||||
<param-name>javax.ws.rs.Application</param-name>
|
||||
<param-value>pack.RestApp</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>resteasy-servlet</servlet-name>
|
||||
<url-pattern>/rest/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
85
TP3/students-server/src/pack/Record.java
Normal file
85
TP3/students-server/src/pack/Record.java
Normal file
|
@ -0,0 +1,85 @@
|
|||
package pack;
|
||||
|
||||
public class Record {
|
||||
|
||||
String INE;
|
||||
String mathematics;
|
||||
String middleware;
|
||||
String networks;
|
||||
String systems;
|
||||
String architecture;
|
||||
String programming;
|
||||
|
||||
public Record() {}
|
||||
|
||||
public Record(String INE, String mathematics, String middleware, String networks, String systems,
|
||||
String architecture, String programming) {
|
||||
super();
|
||||
this.INE = INE;
|
||||
this.mathematics = mathematics;
|
||||
this.middleware = middleware;
|
||||
this.networks = networks;
|
||||
this.systems = systems;
|
||||
this.architecture = architecture;
|
||||
this.programming = programming;
|
||||
}
|
||||
|
||||
public String getINE() {
|
||||
return INE;
|
||||
}
|
||||
|
||||
public void setINE(String INE) {
|
||||
this.INE = INE;
|
||||
}
|
||||
|
||||
public String getMathematics() {
|
||||
return mathematics;
|
||||
}
|
||||
|
||||
public void setMathematics(String mathematics) {
|
||||
this.mathematics = mathematics;
|
||||
}
|
||||
|
||||
public String getMiddleware() {
|
||||
return middleware;
|
||||
}
|
||||
|
||||
public void setMiddleware(String middleware) {
|
||||
this.middleware = middleware;
|
||||
}
|
||||
|
||||
public String getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
||||
public void setNetworks(String networks) {
|
||||
this.networks = networks;
|
||||
}
|
||||
|
||||
public String getSystems() {
|
||||
return systems;
|
||||
}
|
||||
|
||||
public void setSystems(String systems) {
|
||||
this.systems = systems;
|
||||
}
|
||||
|
||||
public String getArchitecture() {
|
||||
return architecture;
|
||||
}
|
||||
|
||||
public void setArchitecture(String architecture) {
|
||||
this.architecture = architecture;
|
||||
}
|
||||
|
||||
public String getProgramming() {
|
||||
return programming;
|
||||
}
|
||||
|
||||
public void setProgramming(String programming) {
|
||||
this.programming = programming;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
19
TP3/students-server/src/pack/RestApp.java
Normal file
19
TP3/students-server/src/pack/RestApp.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package pack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
public class RestApp extends Application {
|
||||
private Set<Object> singletons = new HashSet<Object>();
|
||||
|
||||
public RestApp() {
|
||||
singletons.add(new Students());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Object> getSingletons() {
|
||||
return singletons;
|
||||
}
|
||||
}
|
126
TP3/students-server/src/pack/Student.java
Normal file
126
TP3/students-server/src/pack/Student.java
Normal file
|
@ -0,0 +1,126 @@
|
|||
package pack;
|
||||
|
||||
public class Student {
|
||||
|
||||
String INE;
|
||||
String firstname;
|
||||
String lastname;
|
||||
String birthdate;
|
||||
String sex;
|
||||
String address;
|
||||
String city;
|
||||
String zip;
|
||||
String country;
|
||||
String phone;
|
||||
String email;
|
||||
|
||||
public Student() {}
|
||||
|
||||
public Student(String INE, String firstname, String lastname, String birthdate, String sex, String address,
|
||||
String city, String zip, String country, String phone, String email) {
|
||||
super();
|
||||
this.INE = INE;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.birthdate = birthdate;
|
||||
this.sex = sex;
|
||||
this.address = address;
|
||||
this.city = city;
|
||||
this.zip = zip;
|
||||
this.country = country;
|
||||
this.phone = phone;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getINE() {
|
||||
return INE;
|
||||
}
|
||||
|
||||
public void setINE(String INE) {
|
||||
this.INE = INE;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getBirthdate() {
|
||||
return birthdate;
|
||||
}
|
||||
|
||||
public void setBirthdate(String birthdate) {
|
||||
this.birthdate = birthdate;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
61
TP3/students-server/src/pack/Students.java
Normal file
61
TP3/students-server/src/pack/Students.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
package pack;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
@Path("/rest")
|
||||
public class Students {
|
||||
|
||||
// bad
|
||||
static Hashtable<String, Student> students = new Hashtable<String, Student>();
|
||||
static Hashtable<String, Record> records = new Hashtable<String, Record>();
|
||||
|
||||
static void addStudent(Student s) {
|
||||
students.put(s.getFirstname() + "-" + s.getLastname(), s);
|
||||
}
|
||||
|
||||
static void addRecord(Record r) {
|
||||
records.put(r.getINE(), r);
|
||||
}
|
||||
|
||||
static {
|
||||
addStudent(new Student("1111111111", "Alain", "Tchana", "18/12/1984", "male", "3 rue Jeff Rouchon", "Toulouse",
|
||||
"31000", "France", "0102030405", "alain.tchana@enseeiht.fr"));
|
||||
addStudent(new Student("2222222222", "Boris", "Teabe", "12/03/1990", "male", "6 rue Paul Biya", "Yaoundé",
|
||||
"xxxxx", "Cameroun", "0607080910", "boris.teabe@enseeiht.fr"));
|
||||
addStudent(new Student("3333333333", "Axel", "Carlier", "05/07/1987", "male", "9 rue Denis Dartus", "Toulouse",
|
||||
"31000", "France", "0102030405", "axel.carlier@enseeiht.fr"));
|
||||
addStudent(new Student("4444444444", "Zouheir", "Hamrouni", "07/10/1970", "male", "2 rue Geraldine Morin",
|
||||
"Toulouse", "31000", "France", "0102030405", "zouheir.hamrouni@enseeiht.fr"));
|
||||
addStudent(new Student("5555555555", "Daniel", "Hagimont", "08/07/1965", "male", "1 Francois Asselineau",
|
||||
"Toulouse", "31000", "France", "0102030405", "daniel.hagimont@enseeiht.fr"));
|
||||
|
||||
addRecord(new Record("1111111111", "12", "14", "11", "5", "16", "18"));
|
||||
addRecord(new Record("2222222222", "11", "7", "15", "16", "16", "2"));
|
||||
addRecord(new Record("3333333333", "9", "18", "11", "15", "16", "20"));
|
||||
addRecord(new Record("4444444444", "7", "19", "13", "5", "16", "18"));
|
||||
addRecord(new Record("5555555555", "9", "12", "11", "18", "3", "18"));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getstudent")
|
||||
@Produces({ "application/json" })
|
||||
public Student getStudent(@QueryParam("firstname") String firstname, @QueryParam("lastname") String lastname) {
|
||||
String key = firstname + "-" + lastname;
|
||||
System.out.println("access student: " + key);
|
||||
return students.get(key);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getrecord")
|
||||
@Produces({ "application/json" })
|
||||
public Record getRecord(@QueryParam("ine") String ine) {
|
||||
System.out.println("access record: " + ine);
|
||||
return records.get(ine);
|
||||
}
|
||||
|
||||
}
|
BIN
TP3/tp-ws.odt
Normal file
BIN
TP3/tp-ws.odt
Normal file
Binary file not shown.
BIN
TP3/tp-ws.pdf
Normal file
BIN
TP3/tp-ws.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue