Académique Documents
Professionnel Documents
Culture Documents
Web Services
Web Services
SOAP/WSDL
JAXWS/JAXB/SAAJ
PierreYvesGibelloJanvier2009
(avecquelquesempruntsDidierDonsez,
enparticulierlesslidesdeprsentationSOAP/WSDL)
Licence:CreativeCommonsAttributionShareAlike
Dfinition
UnWSestuncomposantlogicielaccessiblevia
lestechnologiesinternet
Fonctionouservicemtieraccessiblepardautres
applications(client,serveur,autreWS)
Utilisationdesprotocolesdisponibles(ex.SOAPsur
HTTP)
UnWSestuneentitquifournitdesservicesla
demande,viauneinterfaceXMLbiendfinie
sousformedemessages
XMLfaitrfrencepourlautomatisationdesflux
mtier
Positionnement
AppelsdeprocduresdistantesenClient/Serveur
CORBA
Multilangage,multiplateforme,MultiVendeurs,OMG
JavaRMI
monolangage:Java,multiplateforme(JVM),SUN
DCOM
multilangages,plateformeWin32,PropritaireMicrosoft
WebServices(ProtocoleSOAP)
multilangages,multiplateforme
RponsesetrequtesenXML
TransportsurRPC,HTTPouautre(SMTP,MOM)
SpcificationindpendanteW3C
CaractristiquesdunWS
accessiblevialeWeb,
exporteuneinterfaceXML
changedesmessagesXMLviales
protocolesduWeb
adaptauxsystmesinterconnectsde
manireflexible(lienstransitoires,
adaptationdynamique)
[localisableviaunannuaire]
Webservicesetstandards
Enjeu:lintroprabilit
Organismesdenormalisation
W3C,Oasis,WSI...
Initiativesprives
Microsoft,IBM,BEA
Opensource
SunMetro(RI),ApacheAxis,ApacheCXF
Base
Securit
Management
WSManagement...
Discovery
UDDI,WSDiscovery
Description
WSDL
Echangedemessages
SOAP
Transport
HTTP,SMTP,JMS...
Transactions
Extensions
BusinessProcess
BPEL,ebXML
WSTransaction,Coordination,BA...
Avanc
WSSecurity,WSTrust,WebSSO...
Architecture
Lesdiffrentsrles
Annuaire
Description
duservice
Rechercher"
"Publier"
WSDL,UDDI
Client
WSDL,UDDI
Lien(bind)
Serveur
service
Description
duservice
RappelsXML
Markup(balisesavecattributs,etcontenu)
<elem[attribut=valeur]*>[valeur]</elem>
<element/>
<!commentaire>
Extensible
Libertdedfinirsespropresdialectes
Validation:DTDouXMLSchema
LeDocument
[Prologue(entte)]
Arbredlments(racineunique)
<meteo>
<villenom=Grenoble>
<temp>14</temp>
</ville>
</meteo>
[Commentairesetinstructionsdetraitement]
Buts
Sparerlasmantiquedelaprsentation
Echangededonnes
Dfinirunesyntaxecommune
Proposerdesdialectesmtierstandards
ex.MathML,SMILdialectesmtier
industriels
Parsing/Validation
Documentbienform
ObitauxrglessyntaxiquesdeXML
Passedansunparsernonvalidant
Documentvalide
Bienform
Obitunestructuretype(DTDouXMLSchema)
Passedansunparservalidantounon
DTD
DocumentTypeDeclaration
Structuredudocument
Descriptiondeslments
Typagefaible(Stringouformatexterne)
Okpourtraitementdedocument
Validationsyntaxiqueetformelle
Edition,affichage,impression...
Exemple
DTD:bulletin.dtd
<!ELEMENTMETEO(VILLE)+>
<!ELEMENTVILLE(TEMP)>
<!ATTLISTVILLENOMCDATA#REQUIRED>
<!ELEMENTTEMP(#PCDATA)>
Note:PCDATA(ParsedCDATA)analysparleparserXML,
contrairementCDATA(characterdata)
XML:
<!DOCTYPEmeteoSYSTEMbulletin.dtd>
<meteo>
<villenom=Grenoble>
<temp>14</temp>
</ville>
</meteo>
XmlSchema
Pluspuissant(etcomplexe)quelaDTD
Typagefort,typescomplexes
Hritagedetypeobjet
Contrlessmantiques
Domainesdedfinition,numrations,unicit
devaleurs...
DomainesNominaux
OuEspacesdenoms:NameSpaces
AssocierunnomuneDTDouunSchma
UtilisationdeDTD/Schmasmultiples
Dfinidansunlment
<meteoxmlns:mto=http://mameteo.com/bulletin>
Prfixerlesentitsparlenomdfini
<mto:villemto:nom=Grenoble></mto:ville>
Exemple
<?xmlversion=1.0encoding=ISO88591?>
<meteoxmlns=http://www.mameteo.com/bulletin
xmlns:mto=http://www.mameteo.com/mesures>
<villenom=Grenoble>
<mto:station>SMH</mto:station>
<tempmto:unite=Celsius>14</temp>
</ville>
</meteo>
CSS
CascadingStyleSheet
Feuillesdestyle
SyntaxenonXML
selecteur{[proprit:valeur;]+}
titre{fontweight:bold;fontsize:15pt;}
Miseenformepure
Pasdemodificationdestructure
Pasdemodificationdecontenu
LesparsersXML
Interchangeables
APIstandard(SAX,StAX)
Formatdesortiestandard(DOM)
Validantsounon
DTDouXmlSchema
SAX
SimpleAPIforXML
ExtensionstandarddeJ2SE(javax.xml.parsers,
org.xml.sax)audpart,www.saxproject.org
LesparsersSAXsontinterchangeables
Envoidvnements
Dbut/findedocument
Dbut/findentit(ex.startElement())
Caractres(contenu)
Validationpossible
SAX:ContentHandler
Etendreorg.xml.sax.helpers.DefaultHandler
SenregistrerauprsduXMLReader
reader.setContentHandler(handler);
Mthodesdegestiondvnement:
startDocument(),endDocument()
startElement(),endElement()
characters(),etc
Implmentationpardfaut(nefaitrien)
DOM
DocumentObjectModel
APIstandard(implmentationsinterchangeables)
Arbrequirefltelastructuredudocument
FormatdesortiestandardpourparserXML
PlateformeWebServices
Intgreauserveurdapplications
Protocolesettransport
SOAPsurHTTP,SMTP,JMS...
Synchrone/asynchrone
Localisationetlien(binding)
Dploiment/Cycledevie
Dploiementdobjetsjava,EJBs
Metadonnes(WSDL)
Administration,Scurit
Outilsdedveloppement
APIsdeniveaumessage(SAAJ,JAXWSdispatch)ou
XML(JAXB)
GnrationdestubsdepuisleWSDLoudeWSdepuisun
POJO(JAXWS)
Quelquesplateformes...
Apache(opensource)
Axis:http://ws.apache.org/axis2
CXF:http://cxf.apache.org
SunMetro/Glassfish(opensource)
https://metro.dev.java.net/
Microsoft.NET
IBMWebSphere
OracleApplicationServer
NuSOAP(PhP)
...
SOAP
SimpleObjectAccessProtocol
AccsdistanceunWebService
Analogueunprotocoledobjetsdistribus
StandardW3C(interoprabilit)
ProtocoledchangedemessagesenXML
Formatdumessage
Encodage
Rglesdchange
PortedeSOAP
SOAPestsimpleetextensible
etdoncilnecouvrepaslesfonctions
suivantes:
Distributedgarbagecollection
Regroupementdemessages
Passagedobjetsparrfrence
Activation(ncessitelepassageparrfrence)
MessageSOAP
Messageunidirectionnel
dunexpditeurversunrcepteur
Structure
Envelope
lmentracine
Namespace:SOAPENV
http://schemas.xmlsoap.org/soap/envelope/
Header
lmentoptionnel
Contientdesentresnonapplicatives
Sessions(SessionIddeservlet/jsp/asp),Transactions(BTP),
Body
Contientlesentresdumessage
Nomduneprocdure,valeursdesparamtres,valeurderetour
Peutcontenirleslments
fault(erreurs)
Enttemessage(Header)
Contientdesentresnonapplicatives
Transactions,sessions,
LattributmustUnderstand
Rienou=0:llmentestoptionnelpourlapplication
rceptrice
=1:llmentdoittrecomprisdelapplicationrceptrice
(sinonchecdutraitementdumessage)
Exemple
<SOAP-ENV:Header>
<t:Transaction xmlns:t="some-URI" SOAPENV:mustUnderstand="1">
5
</t:Transaction>
</SOAP-ENV:Header>
Corpsdumessage(Body)
Contientdesentresapplicatives
Encodagedesentres
Namespacepourlencodage
SOAPENC
http://schemas.xmlsoap.org/soap/encoding/
xsd:XMLSchema
Encodage
Typesprimitifs
<elementname="price"type="float"/><price>15.57</price>
<elementname="greeting"type="xsd:string"/><greetingid="id1">Bonjour</greeting>
Structures
<elementname="Book"><complexType>
<elementname="author"type="xsd:string"/>
<elementname="title"type="xsd:string"/>
</complexType></element>
<e:Book>
<author>J.R.RTolkien</author>
<title>BilboleHobbit</title>
</e:Book>
Rfrences
<elementname="salutation"type="xsd:string"/><salutationhref="#id1"/>
Tableaux
<SOAPENC:Arrayid="id3"SOAPENC:arrayType=xsd:string[2,2]>
<item>r1c1</item><item>r1c2</item><item>r2c1</item><item>r2c2</item>
</SOAPENC:Array>
Exemplederequte(HTTP)
Demande de cotation un serveur
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV
="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePrice xmlns:m="Some-URI">
<symbol>IBM</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Exemplederponse(HTTP)
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
<SOAP-ENV:Envelope
xmlns:SOAP-ENV
="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle
="http://schemas.xmlsoap.org/soap/encoding/"/>
<SOAP-ENV:Body>
<m:GetLastTradePriceResponse
xmlns:m="Some-URI">
<Price>34.5</Price>
</m:GetLastTradePriceResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Retourderreur(Fault)
4lments
Faultcode(obligatoire)
Codederreurutilisparlelogiciel(switch(faultcode){case)
Faultstring(obligatoire)
Explicationlisibleparunhumain
faultactor(optionnel)
Erreurencoursdecheminementdumessage(firewall,proxy,MOM)
Detail
DtaildelerreurnonliauBodydumessage
Autres
Dautreslmentsqualifisparunnamespacepeuventtreajouts
Faultcode
4groupesdecodederreur
Client,Server,MustUnderstand,VersionMismatch
Ex:Client.Authentication
WSDL
WebServicesDescriptionLanguage
Objectifs
Dcrirelesservicescommeunensembledoprations
etdemessagesabstraitsreli(bind)desprotocoleset
desserveursrseaux
GrammaireXML(schemaXML)
Modulaire(importdautresdocumentsWSDLetXSD)
WSDL:structure
<types>
Contientlesdfinitiondetypesutilisantunsystmedetypage(comme
XmlSchema).
<message>
Dcritlesnomsettypesdunensembledechampstransmettre
Paramtresduneinvocation,valeurduretour,
<porttype>
Dcritunensembledoprations.Chaqueoprationazroouun
messageenentre,zroouplusieursmessagesdesortieoudefautes
<binding>
Spcifieuneliaisondun<porttype>unprotocoleconcret(SOAP1.1,
HTTP1.1,MIME,).Unporttypepeutavoirplusieursliaisons.
<port>
Spcifieunpointdentre(endpoint)commelacombinaisondun
<binding>etduneadresserseau.
<service>
Unecollectiondepointsdentre(endpoint)relatifs.
Messages:exemple
<!-- message declarations -->
<message name="AddEntryRequest">
<part name="name" type="xsd:string"/>
<part name="address" type="typens:address"/>
</message>
<message
name="GetAddressFromNameRequest">
<part name="name" type="xsd:string"/>
</message>
<message
name="GetAddressFromNameResponse">
<part name="address" type="typens:address"/>
</message>
PortType:exemple
<!-- port type declarations (un porttype est un ensemble
doprations)-->
<portType name="AddressBook">
<! One way operation -->
<operation name="addEntry">
<input message="AddEntryRequest"/>
</operation>
<! Request-Response operation -->
<operation name="getAddressFromName">
<input message="GetAddressFromNameRequest"/>
<output message="GetAddressFromNameResponse"/>
</operation>
</portType>
UDDI
UniversalDescription,Discovery,andIntegration
Annuairedewebservices
PourchaqueWS:identifiantunique,etdescription
dtaille(enWSDL)
APIs:JAXR(JavaAPIforXMLregistries)
UDDIdfinitunmodlededonnes(enXML)et
desinterfacesSOAPpourlenregistrementde
WS,etlarecherchedinformation.
Alternative:LDAP?
LesAPIjava/WS
JAXWS(JavaAPIforXMLWS)
Webservices(serveuretclient)
APIsXML
JAXB(JavaArchitectureforXMLbinding):
mappingparamtrableXML/JavaBeans
Parsing:StAX(StreamingAPI=pullparsing),
SAX(SimpleAPIforXml=pushparsing)
JAXB
JavaArchitectureforXMLBinding
https://jaxb.dev.java.net
Source:SunDeveloperNetwork
Liaison(binding)XSD/java
<?xmlversion="1.0"encoding="UTF8"?>
<!meteo.xsd:XMLSchemapourrelevesdetemperature>
<xs:schemaxmlns:tns="mameteo"
xmlns:xs="http://www.w3.org/2001/XMLSchema"targetNamespace="mameteo"
version="1.0">
<xs:elementname="meteo"type="tns:meteo"></xs:element>
<xs:complexTypename="meteo">
<xs:sequence>
<xs:elementname="ville"type="xs:string"></xs:element>
<xs:elementname="temperature"type="xs:float"></xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
Liaisonauschma(binding):gnrationdecodejava
pourunmarshalling/marshalling(XML>java/java>XML)
xjcpmameteometeo.xsd
Package:mameteo
Codejavagnr
Uneclassepartypecomplexe
Meteo.java(javabeanavecaccesseursget/set
pourVilleetTemperature)
UneclasseObjectFactory
Mthodespourcrerchaquetypecomplexeet
chaquelmentduschma
Marshalling(java>XML)
JAXBContextctx=JAXBContext.newInstance("mameteo");
//Utilisationdumappingpourcrerl'arbreXML
ObjectFactoryfactory=newObjectFactory();
Meteodata=factory.createMeteo();
data.setVille("Grenoble");
data.setTemperature(12);
Marshallermarshaller=ctx.createMarshaller();
marshaller.setProperty(
Marshaller.JAXB_FORMATTED_OUTPUT,true);
//EcrituredesdonnesXMLdansunfichier
marshaller.marshal(factory.createMeteo(data),
newFileOutputStream("grenoble.xml"));
Unmarshalling(XML>java)
JAXBContextctx=JAXBContext.newInstance("mameteo");
Unmarshallerdec=ctx.createUnmarshaller();
//LecturedufluxXML,constructiondel'arbre
JAXBElement<Meteo>document=dec.unmarshal(
newjavax.xml.transform.stream.StreamSource(newFile("grenoble.xml")),
Meteo.class);
//UtilisationdumappingJAXB
Meteom=document.getValue();
System.out.println(m.getVille()+":"+m.getTemperature());
JAXWS
JavaAPIforXMLWS(javax.xml.ws)
IntgrJ2SE6+
CachelacomplexitdeSOAP
Gnrationdeproxy(stub)client
Dploiementserveurparannotations
Spcificationd'interfaceWSDLoujava
Synchrone/asynchrone
OutilsJ2SE1.6+
wsimport
Generationdestubspartird'unedescriptionWSDL
wsgen/apt
AnnotationsWebServices
xjc
JAXB:GnrateurXSD>JAVA
schemagen
JAXB:Gnrateurjava>XSD
JAXWSEndPoint
Implmentationctserveur
ServiceEndpointInterface
Interfacejava(expliciteouimplicite:classe)
Annotations:@WebService/@WebMethod...
Mthodesmtier:paramtres/retours
compatiblesJAXB
Constructeurpublicpardfaut,pasdefinalize()
Cycledevie
Annotations:@PostConstruct/@PreDestroy
Endpoint:Exemple(1)
packagecalculette;
importjavax.jws.*;
//Compilation:javacd.puiswsgencp.(ouaptd.)
@WebService
publicclassCalculette{
@WebMethod
publicintaddition(intn1,intn2){returnn1+n2;}
@WebMethod
publicintsoustraction(intn1,intn2){returnn1n2;}
}
EndPoint:Exemple(2)
packagecalculette;
importjavax.xml.ws.Endpoint;
//ServeurwebexportantleWS(lanceravecjava)
publicclassCalcServer{
publicstaticvoidmain(Stringargs[])throwsException{
Stringport="8080";
if(args.length>0)port=args[0];
Endpointendpoint=Endpoint.publish(
"http://localhost:"+port+"/calculette",newCalculette());
System.out.println("WSDL:http://localhost:8080/calculette?wsdl");
System.out.println("XSD:http://localhost:8080/calculette?xsd=1");
}
}
Client:exemple
Gnrationdustub:
wsimportpstub.s.http://localhost:8080/calculette?wsdl
d=rpertoirecible,s=ciblepourlessourcesjava
Stubgnr(classesutilisablesdansleclient):
Uneinterface(ServiceEndpointInterfaceouSEI)par
portduWSDL(ex.Calculette)
UneclasseparserviceduWSDL(ex.CalculetteService)
MappingJAXB:1classeparmessageduWSDL(ex.
Addition,AdditionResponse),et1classeObjectFactory
Ecritureduclient
Calculetteport=newCalculetteService().getCalculettePort();
System.out.println("1+2="+port.addition(1,2));
EnpartantduWSDL
Gnrationdesstubs(etdumappingJAXB)
avecwsimport
Ecritured'uneclassequiimplmentela
ServiceEndpointInterfacegnre
Annotation@WebService
(endpointInterface=interfaceGeneree)
Annotations@Webmethodpour
l'implmentationdesmthodesdel'interface
Debug:tcpmon
https://tcpmon.dev.java.net
Lancementtcpmon
javajartcpmon.jar
Configurationtcpmon
Localport:8080
Servername:127.0.0.1
Serverport:8180
SEIetclient
WebServicesur8180
Clientseconnecte8080
Lesrequtessontvisibles
Intercepteurs
Handlers
Messageentrant,sortant,fault
ImplmenteLogicalHandlerouSOAPHandler
Packagejavax.xml.ws.handler[.soap]
PossibilitdedfinirunechanedeHandlers
Dclaration
Annotation@HandlerChain(file=handlers.xml)
Appliquelaclassed'implmentationduWebService
MthodesetHandlerChain()dejavax.xml.ws.Binding
endPoint.getBinding();
Usage:logging,scurit,modificationdecontenu
Handlers:exemple(dclaration)
@WebService
@HandlerChain(file="handlers.xml")
publicclassCalculette{
//...
}
<?xmlversion="1.0"encoding="UTF8"?>
<!handlers.xml>
<handlerchainsxmlns="http://java.sun.com/xml/ns/javaee">
<handlerchain>
<handler>
<handlerclass>calculette.LogHandler</handlerclass>
</handler>
</handlerchain>
</handlerchains>
Handlers:exemple(code)
publicclassLogHandlerimplementsSOAPHandler<SOAPMessageContext>{
publicbooleanhandleMessage(SOAPMessageContextsmc){
try{
smc.getMessage().writeTo(System.out);
}catch(Exceptionignore){}
returntrue;
}
publicbooleanhandleFault(SOAPMessageContextsmc){
returnhandleMessage(smc);
}
publicSet<QName>getHeaders(){returnnull;}
publicvoidclose(MessageContextmessageContext){}
}
Leproblmedelarentrance
UnWSn'estpasrentrant
Collisionssimisesjourconcurrentes
Contournementspossibles
Patternfacadeavecmaintiendesessionpar
leclient
SessionIdaffectparleWS,ouutilisationde
mcanismesintgrsautransport(sessionHTTP)
Mthodesdemisejoursynchronized
WebServiceContext
Accsaucontextedumessage
HTTP:principauxenttesetcontexteservlet
Scurit:getUserPrincipal(),isUserInRole(role)
Intialisparinjectiondedpendance
Annotation@Resource(javax.annotation.Resource)
@WebService
publicclassHello{
@Resource
privatejavax.xml.ws.WebServiceContextwsContext;
//...
}
Exemple:accslasessionHTTP
Mthodedemaintiendesession
SurtransportHTTP
WebServiceavecscopesession
Moyendecontournerlesproblmesderentrance
MessageContextmc=wsContext.getMessageContext();
HttpServletRequestreq=
(HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST);
HttpSessionsession=req.getSession(true);
Invocationasynchrone
Apreciserlorsdel'appelwsimport
bindingwsimport:optionb
EnableAsyncMapping=true
GnrationdemthodesxxxAsyncpourchaque
oprationxxx
2modlesdeprogrammation
Polling
Callback
Asynchrone:bindingwsimport
<?xmlversion="1.0"encoding="UTF8"standalone="yes"?>
<!fichierafournirenoptionbdewsimport>
<bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="http://localhost:8080/calculette?wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
<bindingsnode="wsdl:definitions">
<enableAsyncMapping>true</enableAsyncMapping>
</bindings>
</bindings>
Asynchrone:polling
importjavax.xml.ws.Response;
//...
//MethodeadditionAsyncgnreparwsimport
//(enableAsyncMapping=true)
Response<AdditionResponse>rsp=port.additionAsync(8,2000);
while(!rsp.isDone()){
System.out.println("Attentereponseenpolling");
Thread.sleep(1000);
}
AdditionResponseresultat=rsp.get();
System.out.println("8+2000="+resultat.getReturn());
Asynchrone:callback(invocation)
importjava.util.concurrent.Future;
//...
AdditionCallbackcallbackHandler=newAdditionCallback();
System.out.println("Attentereponseencallback");
//Enregistrementdulistener(classegestionnaire)
//MethodeadditionAsyncgnreparwsimport(enableAsyncMapping)
Future<?>response=port.additionAsync(8,2000,callbackHandler);
Thread.sleep(7000);
if(response.isDone()){
AdditionResponseresult=callbackHandler.getResultat();
System.out.println("8+2000="+result.getReturn());
}
Asynchrone:callback(gestionnaire)
//Classegestionnaire(listener)enregistrer
publicclassAdditionCallback
implementsAsyncHandler<AdditionResponse>{
AdditionResponseresultat_;
//Mthodecallbackappelel'arrived'unerponse
publicvoidhandleResponse(Response<AdditionResponse>response){
System.out.println("Receptionreponse");
try{
resultat_=response.get();
}catch(Exceptione){e.printStackTrace();}
}
publicAdditionResponsegetResultat(){returnresultat_;}
SAAJ
SOAPwithAttachmentsforJava
javax.xml.soap
Avantages:attachementsMIME
Inconvnients:APIbasniveau(SOAP)
APIdeniveaumessage
SOAPConnectionFactory/SOAPConnection
SOAPMessage
(SOAPPart(SOAPEnvelope(SOAPBody(SOAPElement)*))
SOAPMessagereply=connection.call(message,
destination);
SAAJ:Exemple
SOAPConnectionFactorysoapCF=SOAPConnectionFactory.newInstance();
SOAPConnectionconnection=soapCF.createConnection();
MessageFactorymessageFactory=MessageFactory.newInstance();
SOAPMessagemessage=messageFactory.createMessage();
SOAPPartsoapPart=message.getSOAPPart();
SOAPEnvelopeenvelope=soapPart.getEnvelope();
SOAPBodybody=envelope.getBody();
SOAPElementbodyElement=body.addChildElement(
envelope.createName("addition","ns1","http://calculette/"));
bodyElement.addChildElement("arg0").addTextNode("1");
bodyElement.addChildElement("arg1").addTextNode("3");
message.saveChanges();
SOAPMessagereply=connection.call(message,"http://localhost:8080/calculette");
SAAJ:Attachement
importjavax.xml.soap.AttachmentPart;
MessageFactorymessageFactory=MessageFactory.newInstance();
SOAPMessagem=messageFactory.createMessage();
AttachmentPartap1=m.createAttachmentPart();
ap1.setContent("CeciestuncoursSAAJ","text/plain");
m.addAttachmentPart(ap1);
AttachmentPartap2=m.createAttachmentPart();
ap2.setRawContent(newFileInputStream("logo.jpg"),"image/jpeg");
m.addAttachmentPart(ap2);
Annexes
Dploiement:formatWAR(Web
ApplicationaRchive)
Dploiement:ApplicationsWeb
Ensembledescomposantsduneapplication
ServletsetJSP,librairiesdeclasses,fichiersde
configuration...
Formatstandarddepackaging
WebApplicationaRchive(fichier.war)
Formatjar,avecorganisationstandard
Dploiementparleconteneurdeservlets
Automatique
Paramtrableparconfiguration
Exemple:dploiementTomcat
Copierlefichier.wardanswebapps/
Redmarrerleserveur
WebApplicationaRchive
m o n a p p liw e b . w a r
h t t p : / / s e r v e u r / m o n a p p liw e b
m o n a p p liw e b
W E B IN F
w e b . x m l c o n f i g u r a t i o n d e l 'a p p l i
c la s s e s
r p e r t o ir e d u c la s s p a t h
lib
. z ip e t . ja r d u c la s s p a t h
R e s s o u r c e s lo c a le s
H T M L , js p . . .