Beruflich Dokumente
Kultur Dokumente
WhatYouShouldAlreadyKnow
Beforeyoucontinueyoushouldhaveabasic understandingofthefollowing: XML XMLNamespaces XMLSchema
WhatisWSDL?
WSDLstandsforWebServicesDescription Language WSDLiswritteninXML WSDLisanXMLdocument WSDLisusedtodescribeWebservices WSDLisalsousedtolocateWebservices WSDLisaW3Crecommendation
WSDLDescribesWebServices
WSDLstandsforWebServicesDescription Language. WSDLisadocumentwritteninXML.The documentdescribesaWebservice.Itspecifies thelocationoftheserviceandtheoperations (ormethods)theserviceexposes.
TheWSDLDocumentStructure
ElementDefines <types>Thedatatypesusedbythewebservice
<message>Themessagesusedbythewebservice <portType>Theoperationsperformedbythewebservice <binding>Thecommunicationprotocolsusedbythewebservice
ThemainstructureofaWSDL documentlookslikethis:
<types> definitionoftypes........ </types> <message> definitionofamessage.... </message> <portType> definitionofaport....... </portType> <binding> definitionofabinding.... </binding> </definitions>
WSDLPorts
The <portType> elementisthemostimportant WSDLelement. Itdescribesawebservice,theoperationsthat canbeperformed,andthemessagesthatare involved. The<portType>elementcanbecomparedtoa functionlibrary(oramodule,oraclass)ina traditionalprogramminglanguage.
WSDLMessages
The <message> elementdefinesthedata elementsofanoperation. Eachmessagecanconsistofoneormore parts.Thepartscanbecomparedtothe parametersofafunctioncallinatraditional programminglanguage.
WSDLTypes
The <types> elementdefinesthedatatypes thatareusedbythewebservice. Formaximumplatformneutrality,WSDLuses XMLSchemasyntaxtodefinedatatypes.
WSDLExample
<messagename="getTermRequest"> <partname="term"type="xs:string"/> </message> <messagename="getTermResponse"> <partname="value"type="xs:string"/> </message> <portType name="glossaryTerms"> <operationname="getTerm"> <inputmessage="getTermRequest"/> <outputmessage="getTermResponse"/> </operation> </portType>
SOAP
WhatisSOAP?
SOAPstandsforSimpleObjectAccessProtocol SOAPisacommunicationprotocol SOAPisforcommunicationbetweenapplications SOAPisaformatforsendingmessages SOAPcommunicatesviaInternet SOAPisplatformindependent SOAPislanguageindependent SOAPisbasedonXML SOAPissimpleandextensible SOAPallowsyoutogetaroundfirewalls SOAPisaW3Crecommendation
WhySOAP?
Itisimportantforapplicationdevelopmenttoallow Internetcommunicationbetweenprograms. Today'sapplicationscommunicateusingRemoteProcedure Calls(RPC)betweenobjectslikeDCOMandCORBA,but HTTPwasnotdesignedforthis.RPCrepresentsa compatibilityandsecurityproblem;firewallsandproxy serverswillnormallyblockthiskindoftraffic. Abetterwaytocommunicatebetweenapplicationsisover HTTP,becauseHTTPissupportedbyallInternetbrowsers andservers.SOAPwascreatedtoaccomplishthis. SOAPprovidesawaytocommunicatebetween applicationsrunningondifferentoperatingsystems,with differenttechnologiesandprogramminglanguages
SOAPBuildingBlocks
ASOAPmessageisanordinaryXMLdocument containingthefollowingelements: AnEnvelopeelementthatidentifiestheXML documentasaSOAPmessage AHeaderelementthatcontainsheader information ABodyelementthatcontainscallandresponse information AFaultelementcontainingerrorsandstatus information
SyntaxRules
Herearesomeimportantsyntaxrules: ASOAPmessageMUSTbeencodedusingXML ASOAPmessageMUSTusetheSOAPEnvelope namespace ASOAPmessageMUSTusetheSOAPEncoding namespace ASOAPmessagemustNOTcontainaDTD reference ASOAPmessagemustNOTcontainXML ProcessingInstructions
<?xmlversion="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soapenvelope" soap:encodingStyle="http://www.w3.org/2001/12/soapencoding"> <soap:Header> ... </soap:Header> <soap:Body> ... <soap:Fault> ... </soap:Fault> </soap:Body> </soap:Envelope>
TheSOAPEnvelopeElement
TherequiredSOAPEnvelopeelementistherootelement ofaSOAPmessage.ThiselementdefinestheXML documentasaSOAPmessage. Example <?xmlversion="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soapenvelope" soap:encodingStyle="http://www.w3.org/2001/12/soap encoding"> ... Messageinformationgoeshere ... </soap:Envelope>
<?xmlversion="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soapenvelope" soap:encodingStyle="http://www.w3.org/2001/12/soap encoding"> <soap:Header> <m:Trans xmlns:m="http://www.w3schools.com/transaction/" soap:mustUnderstand="1"> soap:actor="http://www.w3schools.com/appml/"> </m:Trans> </soap:Header> ... ... </soap:Envelope>
ThemustUnderstand Attribute
TheSOAPmustUnderstand attributecanbeused toindicatewhetheraheaderentryismandatory oroptionalfortherecipienttoprocess. IfyouaddmustUnderstand="1"toachild elementoftheHeaderelementitindicatesthat thereceiverprocessingtheHeadermust recognizetheelement.Ifthereceiverdoesnot recognizetheelementitwillfailwhenprocessing theHeader.
TheactorAttribute
ASOAPmessagemaytravelfromasenderto areceiverbypassingdifferentendpoints alongthemessagepath. However,notallpartsofaSOAPmessage maybeintendedfortheultimateendpoint, instead,itmaybeintendedforoneormoreof theendpointsonthemessagepath. TheSOAPactorattributeisusedtoaddress theHeaderelementtoaspecificendpoint.
TheencodingStyle Attribute
TheencodingStyle attributeisusedtodefine thedatatypesusedinthedocument.This attributemayappearonanySOAPelement, anditwillapplytothatelement'scontents andallchildelements. ASOAPmessagehasnodefaultencoding.
TheSOAPFaultElement
TheoptionalSOAPFaultelementisusedto indicateerrormessages. IfaFaultelementispresent,itmustappearas achildelementoftheBodyelement.AFault elementcanonlyappearonceinaSOAP message.
TheSOAPFaultelementhasthe followingsubelements:
SubElementDescription <faultcode>Acodeforidentifyingthefault <faultstring>Ahumanreadableexplanationofthefault <faultactor>Informationaboutwhocausedthefaulttohappen <detail>Holdsapplicationspecificerrorinformationrelatedto theBodyelement