$WEB_SERVER/webapps/axis/WEB-INF/lib/
<servlet-mapping>dans
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
$WEB_SERVER/webapps/axis/WEB-INF/web.xml
$ pythonC'est beau l'interopérabilité !
>>> import SOAPpy
>>> client = SOAPpy.SOAPProxy("http://localhost:8080/axis/services/Version")
>>> print client.getVersion()
Apache Axis version: 1.2beta
Built on Mar 31, 2004 (12:47:03 EST)
>>> client = SOAPpy.SOAPProxy("http://localhost:8080/axis/StockQuoteService.jws")Python utilise l'information de type renvoyée par SOAP pour renvoyer le bon type (float ici). On peut voir le message brut avec avec un navigateur:
>>> print client.getQuote("XXX")
66.25
http://localhost:8080/axis/StockQuoteService.jws?method=getQuote&arg=XXX
samples/userguide/example2dans:
$WEB_SERVER/webapps/axis/avec le suffixe .jws . Cette fois côté client, pour changer, on ne passe pas par SOAPpy, mais on utilise wget, l'aspirateur de site en ligne de commande. Cela permet de voir les entêtes HTTP renvoyés par Axis. On utilise donc une requête de type GET; pour Axis, le nom des arguments est alors indifférent.
$ wget --save-headers -O - 'http://localhost:8080/axis/Calculator.jws?method=add&i=33&j=55'
--21:54:13-- http://localhost:8080/axis/Calculator.jws?method=add&i=33&j=55
=> `-'
Résolution de localhost... complété.
Connexion vers localhost[127.0.0.1]:8080...connecté.
requête HTTP transmise, en attente de la réponse...200 OK
Longueur: non spécifié [text/xml]
HTTP/1.1 200 OK
Date: Sun, 23 May 2004 19:54:13 GMT
Server: Jetty/4.2.18 (Linux/2.4.22-1.2188.nptl i386 java/1.4.2_01)
Cache-Control: no-cache
Pragma: no-cache
Content-Type: text/xml
Connection: close
[<=> ] 0 --.--K/s <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<addResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<addReturn href="#id0"/>
</addResponse>
<multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">88</multiRef>
</soapenv:Body>
</soapenv:Envelope>
[ <=> ] 590 576.17K/s
21:54:13 (576.17 KB/s) - « - » sauvegardé [590]
On peut voir le WSDL généré par Axis:
http://localhost:8080/axis/Calculator.jws?wsdl
http://services.xmethods.net/axis/getQuote?s=SUNCe site regroupe plein de services Web utilisables à des fin de démo.
setup.batIl faut avoir installé Calculator.jws côté serveur comme expliqué ci-dessus .
java -classpath .;%AXISCLASSPATH% samples/userguide/example2/CalcClient add 11 22
$ cd /home/jmv/install2/axis-1_2Qu'a-t-on fait ici ? Le programme AdminClient s'est adressé au service Web
$ source setup.sh; echo $AXISCLASSPATH
$ cd samples/stock
$ java -cp $AXISCLASSPATH org.apache.axis.client.AdminClient \
-lhttp://localhost:8080/axis/services/AdminService deploy.wsdd
Processing file deploy.wsdd
<Admin>Done processing</Admin>
http://localhost:8080/axis/services/AdminServicepour lui demander de déployer ce qui est spécifié dans le fichier deploy.wsdd .
org.apache.axis.client.AdminClientest d'utiliser un Run d'eclipse. Il suffit alors d'indiquer les même arguments avec soit le chemin complet de deploy.wsdd, soit entrer comme "Working directory":
axis-1_2/samples/stockPour regarder commodément deploy.wsdd - Truc avec vim pour associer le type xml au suffixe .wsdd
# compiler l'exemple:Voici le code complet d'un client typique, laborieux et beaucoup de casts, par rapport à Python. Il Permet d'obtenir une quotation boursière, voir http://xmethods.com/ ( Delayed Stock Quote ).
cd samples/stock; ant; cd ../..
# exécution:
java -cp $AXISCLASSPATH:build/classes/ samples.stock.GetQuote \
-lhttp://localhost:8080/axis/servlet/AxisServlet -uuser1 -wpass1 XXX
XXX: 55.25
import java.rmi.RemoteException;
import javax.xml.namespace.QName;
import javax.xml.rpc.Call;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.client.Service;
public class Client1 {
static void callWebService( String url, String ns, String stock_symbol ) throws ServiceException, RemoteException {
Service service = new Service();
Call call = service.createCall();
call.setTargetEndpointAddress( url );
call.setOperationName( new QName( ns, "getQuote" ) );
call.addParameter( "symbol", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_FLOAT );
Float resu = (Float)call.invoke( new Object[] {stock_symbol} );
System.out.println(resu);
}
public static void main(String [] args) throws RemoteException, ServiceException {
callWebService( "http://64.124.140.30:9090/soap",
"urn:xmethods-delayed-quotes", "SUN" );
}
}
source setup.sh # remplit variable $AXISCLASSPATH
javac -g samples/userguide/example6/WidgetPrice.java # compile une interface
java -cp .:$AXISCLASSPATH org.apache.axis.wsdl.Java2WSDL -o wp.wsdl \
-l"http://localhost:8080/axis/services/WidgetPrice" -n "urn:Example6" \
-p"samples.userguide.example6" "urn:Example6" \
samples.userguide.example6.WidgetPrice
$ java -cp $AXISCLASSPATH:. org.apache.axis.wsdl.WSDL2Java -o src-gen \Comment utiliser ces sources générés ?
-d Session -s -S true --testCase -Nurn:Example6 samples.userguide.example6 wp.wsdl
$ ls -l src-gen/samples/userguide/example6
total 40
-rw-rw-r-- 1 jmv jmv 1252 mai 24 17:04 deploy.wsdd
-rw-rw-r-- 1 jmv jmv 672 mai 24 17:04 undeploy.wsdd
-rw-rw-r-- 1 jmv jmv 451 mai 24 17:04 WidgetPrice.java
-rw-rw-r-- 1 jmv jmv 556 mai 24 17:04 WidgetPriceService.java
-rw-rw-r-- 1 jmv jmv 4919 mai 24 17:04 WidgetPriceServiceLocator.java
-rw-rw-r-- 1 jmv jmv 539 mai 24 17:04 WidgetPriceSoapBindingImpl.java
-rw-rw-r-- 1 jmv jmv 3813 mai 24 17:04 WidgetPriceSoapBindingSkeleton.java
-rw-rw-r-- 1 jmv jmv 6478 mai 24 17:04 WidgetPriceSoapBindingStub.java
cd src-gen; javac -classpath .:$AXISCLASSPATH samples/userguide/example6/*.java
java -cp .:$AXISCLASSPATH org.apache.axis.client.AdminClient \
-lhttp://localhost:8080/axis/services/AdminService samples/userguide/example6/deploy.wsdd
import samples.userguide.example6.*;
public class MainTest {
public static void main (String[] args) throws Exception {
samples.userguide.example6.WidgetPrice binding = new WidgetPriceServiceLocator().getWidgetPrice();
((WidgetPriceSoapBindingStub)binding).setMaintainSession(true);
try {
((WidgetPriceSoapBindingStub) binding).setWidgetPrice("FOO", "$1.00");
} catch (java.rmi.RemoteException re) {
throw new Exception("Remote Exception caught: " + re );
}
try {
java.lang.String value = null;
value = binding.getWidgetPrice("FOO");
System.out.println("value: " + value);
if (value == null ||
!value.equals("$1.00"))
System.out.println("Wrong Price" + value);
} catch (java.rmi.RemoteException re) {
throw new Exception("Remote Exception caught: " + re );
}
}
}
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="OrderProcessor" provider="java:RPC">
<parameter name="className" value="samples.userguide.example5.BeanService"/>
<parameter name="allowedMethods" value="processOrder"/>
<beanMapping qname="myNS:Order" xmlns:myNS="urn:BeanService"
languageSpecificType="java:samples.userguide.example5.Order" />
</service>
</deployment>
for f in build/lib/*.jar lib/*.jar; do CLASSPATH=$CLASSPATH:$f ; doneOn peut alors lancer l'invoqueur dynamique:
CLASSPATH=$CLASSPATH:./build/samples
java clients.DynamicInvoker 'http://localhost:8080/axis/services/Version?wsdl' getVersion
Reading WSDL document from 'http://localhost:8080/axis/services/Version?wsdl'
Preparing WSIF dynamic invocation
- WSIF0006W: Plusieurs WSIFProvider trouvés, supportant l' URI du même espace de nom 'http://schemas.xmlsoap.org/wsdl/soap/'. ('org.apache.w
sif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis, org.apache.wsif.providers.soap.apachesoap.WSIFDynamicProvider_ApacheSOAP') tro
uvé.
- WSIF0007I: Utilisation de WSIFProvider 'org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis' pour namespaceURI 'http:
//schemas.xmlsoap.org/wsdl/soap/'.
Executing operation getVersion
Result:
getVersionReturn=Apache Axis version: 1.2RC1
Built on Sep 26, 2004 (06:07:18 CEST)
Done!
admin mot_de_passeEnsuite dans le répertoire d'installation de Axis:
source ./setup.sh
echo $AXISCLASSPATH
java -classpath $AXISCLASSPATH org/apache/axis/utils/SOAPMonitor \
-l http://localhost:8080/axis/servlet/AxisServlet
-u admin -w mot_de_passe &
apt-get install python-docs
export PYTHONDOCS=/usr/share/doc/python-docs-2.2.3/html
import SOAPpyEt le client correspondant :
def hello():
return "Hello World"
server = SOAPpy.SOAPServer(("localhost", 8080))
server.registerFunction(hello)
server.serve_forever()
import SOAPpyOn voit que l'aspect dynamique de Python est mis à profit. Pas besoin des étapes laborieuses d'un appel WS en Java avec l'API Sun officielle, Java API for XML-Based RPC (JAX-RPC) !
client = SOAPpy.SOAPProxy("http://localhost:8080/")
print client.hello()
>> help("SOAPpy.SOAPProxy")Comme exemple de service, on va prendre Delayed Stock Quote, fourni par xmethods.net; on extrait de la doc cet exemple d'appel:
Help on class SOAPProxy in SOAPpy:
SOAPpy.SOAPProxy = class SOAPProxy
| ################################################################################
| # SOAP Proxy
| ################################################################################
|
| Methods defined here:
|
| _SOAPProxy__call = __call(self, name, args, kw, ns=None, sa=None, hd=None, ma=None)
|
| __getattr__(self, name)
|
| __init__(self, proxy, namespace=None, soapaction=None, header=None, methodattrs=None, transport=<class SOAPpy.Clie
nt.HTTPTransport>, encoding='UTF-8', throw_faults=1, unwrap_results=None, http_proxy=None, config=<SOAPpy.Config.SOAPC
onfig instance>, noroot=0, simplify_objects=None)
|
| _callWithBody(self, body)
|
| invoke(self, method, args)
<SOAP-ENV:Body>
<ns1:getQuote xmlns:ns1="urn:xmethods-delayed-quotes"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<symbol xsi:type="xsd:string">IBM</symbol>
</ns1:getQuote>
</SOAP-ENV:Body>
A partir de là, voici le code Python :import SOAPpy
client = SOAPpy.SOAPProxy("http://66.28.98.121:9090/soap",
namespace="urn:xmethods-delayed-quotes" )
print client.getQuote(symbol="IBM")
Document | Language | Original | Translator | Date |
---|---|---|---|---|
SOAP Version 1.2, partie 0: Préliminaire | French | Rec: SOAP Version 1.2 Part 0: Primer | Carine Bournez | 24 June 2003 |
SOAP Version 1.2 Partie 1: Structure pour l'échange de messages | French | REC: SOAP Version 1.2 Part 1: Messaging Framework | Carine Bournez | 24 June 2003 |
SOAP Version 1.2 Partie 2: Ajouts | French | PR: SOAP Version 1.2 Part 2: Adjuncts | Carine Bournez | 24 June 2003 |
Once these are implemented, XML Key Management is likely to be the next focus for the project.
Web Services Essentials | Feb 2002 |
Algorithm::Evolutionary | Algorithm::Evolutionary provides classes for performing simple evolutionary computation tasks, including definition of objects from XML and SOAP support. It should be interoperable with other EC libraries using SOAP. | ||
SMUD (SOAP-able Multi User Dungeon) | This project will be used to create a multi-user dungeon (MUD) loosly based on the "Dungeons & Dragons" world. The most important aspect of this server is that it accepts client connections via SOAP/XML envelopes. Fun. |
... October 2003: Semantic Web
Services Interest Group launched; June 2003: SOAP
Version 1.2 released as a W3C Recommendation (press release,
testimonials, changes ... www.w3.org/2002/ws/ - 20k - 21 mai 2004 - En cache - Pages similaires |
Google Web APIs - Home - [ Traduire cette page ]
... Google uses the SOAP
and WSDL standards so a developer can program in his or ... and
a WSDL file for writing programs on any platform that supports web
services. ... www.google.com/apis/ - 12k - En cache - Pages similaires |
WebServices.Org - The Web Services Industry Portal - - [ Traduire cette page ]
... Your WSDL. ( 19.09.2003
10:04 ). SOAP has received considerable attention as a flagship
standard for interoperable services; however, as Web services
move to ... www.webservices.org/ - 93k - 21 mai 2004 - En cache - Pages similaires |
WebServices - Axis - [ Traduire cette page ]
... This project is a
follow-on to the Apache SOAP project. ... Axis 1.1 has
proven itself to be a reliable and stable base on which to implement
Java Web Services. ... ws.apache.org/axis/ - 13k - 21 mai 2004 - En cache - Pages similaires |
developerWorks : Web services - [ Traduire cette page ]
... Extend JAX-RPC Web
services using SOAP headers: Learn how SOAP
handlers create and process SOAP message headers and how to
configure handlers appropriately. ... www-106.ibm.com/developerworks/webservices/ - 57k - En cache - Pages similaires |
Web Services Developer Center Home - [ Traduire cette page ]
... COM Components
Integrating Web Services and COM Components Eliminate
organizational dependence on the SOAP Toolkit to expose COM
components as Web services. ... msdn.microsoft.com/webservices/ - 36k - 21 mai 2004 - En cache - Pages similaires |
WSDL, SOAP, Web Services Search Engine and Web Service Tracking - [ Traduire cette page ]
Web Services Library
and SOAP Schema Library. A library of web services
applications. Web ... WSDL / SOAP Web Services
Search Engine. The ... www.salcentral.com/ - 32k - 21 mai 2004 - En cache - Pages similaires |
export ANT_HOME=
export JAVA_HOME=
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic login
cvs -d :pserver:anoncvs@cvs.apache.org:/home/cvspublic checkout ws-axis
cd java
unset CLASSPATH
ant war
[...]
war:
[copy] Copying 8 files to /usr/src/ws-axis/java/build/webapps/axis/WEB-INF/lib
[copy] Copying 27 files to /usr/src/ws-axis/java/build/webapps/axis/samples
[copy] Copied 21 empty directories to 13 empty directories under /usr/src/ws-axis/java/build/webapps/axis/samples
[copy] Copying 56 files to /usr/src/ws-axis/java/build/webapps/axis/WEB-INF/classes/samples
[jar] Building jar: /usr/src/ws-axis/java/build/axis.war
BUILD SUCCESSFUL
cp build/axis.war $WEBAPPS # déployer Axis
Java(TM) Web Services Developer Pack 1.4 sera installé à l'emplacement ci-après :On a à la fin ce message pas très clair:
/home/jmv/usr2/jwsdp-1.4
avec les fonctions suivantes :
XML Digital Signature Version 1.0 EA XML and Web Services Security Version 1.0 EA3 WS-I Attachments Sample Application Version 1.0 EA JAXB Version 1.0.3 (Java Architecture for XML Binding) JAXP Version 1.2.6 (Java API for XML Processing) JAXR Version 1.0.6 (Java API for XML Registries) JAX-RPC Version 1.1.2 (Java API for XML-based RPC) SAAJ Version 1.2.1 (SOAP with Attachments API for Java) JSTL Version 1.1 (JavaServer Pages(TM) Standard Tag Library) Java WSDP Registry Server Version 1.0_06
pour une taille totale de :
75 Mo
In this version of Java(TM) Web Services Developer Pack, the org.apache JAXP packages have been renamed.On nous indique ensuite que les pages de doc. sont ici :
As a result, the use of the java.endorsed.dirs system property is no longer necessary for
standalone Java(TM) applications which use JDK 1.4.x to work.
If you write standalone Java applications, all that is now needed is to include the JAXP jar files
at the beginning of the CLASSPATH.
jwsdp-1.4/docs/GettingStarted.htmlet qu'on démarre tomcat de la façon habituelle:
/home/jmv/usr2/tomcat-jwsdp-1.4/bin/catalina.sh startWeb Services Tutorial - June 21, 2004
augroup filetypedetect
au! BufNewFile,BufRead *.wsdd setf xml
augroup END