sysrep:tp2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
sysrep:tp2 [2013/11/20 14:14] – 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 23: | 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> | ||
Line 36: | 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 84: | 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==== |
sysrep/tp2.1384956883.txt.gz · Last modified: 2024/03/18 15:05 (external edit)