sysrep:tp2
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| sysrep:tp2 [2012/11/14 12:32] – orel | sysrep:tp2 [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ====== TP2 : Web Services ====== | ====== TP2 : Web Services ====== | ||
| + | On suppose le serveur Apache Tomcat correctement installé (cf. TP1). | ||
| - | Guide utilisateur : http:// | + | __Documentation__ |
| - | On suppose le serveur Apache Tomcat correctement installé (cf. TP1). | + | * Guide utilisateur Axis : http://ws.apache.org/ |
| + | * Un peu d'aide sur WSDL : http:// | ||
| ==== Installation de Axis ==== | ==== Installation de Axis ==== | ||
| Line 12: | Line 14: | ||
| nomme ce répetoire < | nomme ce répetoire < | ||
| - | wget http:// | + | wget http:// |
| + | wget http:// | ||
| + | | ||
| Configurer votre environnement Bash. | Configurer votre environnement Bash. | ||
| Line 22: | Line 25: | ||
| ==== Déploiement avec JWS==== | ==== Déploiement avec JWS==== | ||
| - | Déployez avec JWS le service web fourni dans le fichier | + | Déployez avec JWS les services webs suivants. |
| - | " | + | |
| - | <code java | HelloWorld.java> | + | <code java HelloWorld.java> |
| public class HelloWorld | public class HelloWorld | ||
| { | { | ||
| Line 35: | Line 37: | ||
| </ | </ | ||
| - | Consultez le guide utilisateur de Axis pour mettre | + | <code java Calculator.java> |
| - | en place ce service et tester | + | public class Calculator { |
| - | votre navigateur web. Afficher | + | public int add(int i1, int i2) { |
| + | return i1 + i2; | ||
| + | } | ||
| + | |||
| + | public int subtract(int i1, int i2) { | ||
| + | return i1 - i2; | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | * Consultez le guide utilisateur de Axis pour mettre en place ce service et tester | ||
| + | * Affichez | ||
| + | |||
| + | ====Client Statique JAX-RPC==== | ||
| + | |||
| + | Récupérez la description WSDL du service HelloWorld, puis générez les stubs avec la commande : | ||
| + | |||
| + | java -cp ${AXIS_HOME}/ | ||
| + | |||
| + | Compilez les fichiers stubs. | ||
| + | |||
| + | Ecrire un client Java statique. Pour ce faire, il faut utiliser la classe " | ||
| + | |||
| + | <code java HelloWorldStaticClient.java> | ||
| + | import java.rmi.RemoteException; | ||
| + | import javax.xml.rpc.ServiceException; | ||
| + | import localhost.axis.HelloWorld_jws.*; | ||
| + | |||
| + | public class HelloWorldStaticClient | ||
| + | { | ||
| + | public static void main(String[ ] args) | ||
| + | throws ServiceException, | ||
| + | { | ||
| + | HelloWorldService locator = new HelloWorldServiceLocator(); | ||
| + | HelloWorld stub = locator.getHelloWorld(); | ||
| + | String returnValue = stub.test(" | ||
| + | System.out.println(returnValue); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Pour compiler et exécuter : | ||
| + | |||
| + | <code bash> | ||
| + | $ javac -cp ${AXIS_HOME}/ | ||
| + | $ java -cp ${AXIS_HOME}/ | ||
| + | </ | ||
| + | |||
| + | ====Utilisation d'un Web Service sur Internet==== | ||
| + | |||
| + | Ecrire un client statique pour un web service SOAP 1.2 trouvé sur le web. | ||
| + | |||
| + | Par exemple : | ||
| + | |||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| ====Client Dynamique JAX-RPC==== | ====Client Dynamique JAX-RPC==== | ||
| Line 83: | Line 142: | ||
| java org.apache.axis.utils.tcpmon [listenPort targetHost targetPort] | java org.apache.axis.utils.tcpmon [listenPort targetHost targetPort] | ||
| - | ====Client Statique JAX-RPC==== | ||
| - | |||
| - | Récupérez l' | ||
| - | "java org.apache.axis.wsdl.WSDL2Java < | ||
| - | derniers. | ||
| - | |||
| - | Ecrire un client Java statique. Pour ce faire, il faut utiliser la | ||
| - | classe " | ||
| - | manipule ensuite comme un objet de type HelloWorld. | ||
| - | |||
| - | <code java HelloWorldStaticClient.java> | ||
| - | import java.rmi.RemoteException; | ||
| - | import javax.xml.rpc.ServiceException; | ||
| - | import localhost.axis.HelloWorld_jws.*; | ||
| - | |||
| - | public class HelloWorldStaticClient | ||
| - | { | ||
| - | public static void main(String[ ] args) | ||
| - | throws ServiceException, | ||
| - | { | ||
| - | HelloWorldService locator = new HelloWorldServiceLocator(); | ||
| - | HelloWorld stub = locator.getHelloWorld(); | ||
| - | String returnValue = stub.test(" | ||
| - | System.out.println(returnValue); | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| ====Déploiement avec WSDD==== | ====Déploiement avec WSDD==== | ||
| Line 150: | Line 182: | ||
| $ java org.apache.axis.client.AdminClient MyServices/ | $ java org.apache.axis.client.AdminClient MyServices/ | ||
| - | |||
sysrep/tp2.1352896324.txt.gz · Last modified: 2024/03/18 15:05 (external edit)
