WSDL Reading, A Beginner's Guide

download WSDL Reading, A Beginner's Guide

of 18

description

Web Services WSDL Guide

Transcript of WSDL Reading, A Beginner's Guide

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 1/18

    WSDLReading,aBeginner'sGuide

    By:ThomasBayerDate:08/24/2009

    ThisarticleexplainshowtoreadaWSDLdocumentbyanalyzingtheWebServicesdescriptionofapublicsampleService.DuringthearticleatreediagramisdevelopedfromthecontentoftheWSDLdocument.ThetreeillustratesthestructureofWSDL.ThereaderwillgetanunderstandingoftheWSDLelementsandtheirrelationships.TherootelementofaWSDLdocumentisdefinitions.SowestarttheWSDLtreewithadefinitionsnodeasroot.

    Seefigure1:

    Figure1:DefinitionandService

    ToanalyseaWSDLdocumentitisrecommendedtoreaditfromthebuttomupwards.Atthebottomofthe

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 2/18

    BLZService'sWSDLwefindachildelementofdefinitionsnamedservice.

    Listing1:ServiceElementThenameoftheserviceisBLZService.Aservicecanhavemultipleportsmarkedinfigure2witha*character.Eachportdescribesawaytoaccesstheservice.InourBLZServiceexampletherearethreeports.OneforSOAP1.1,oneforSOAP1.2andonefortheHTTPbinding.

    Figure2:PortsofaService

    Let'shavealookatthefirstportinlisting2.

    1234567891011

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 3/18

    Listing2:PortdescribingaSOAP1.1EndpointIt'schildelementaddresshasadifferentXMLprefixthantheotherelements.TheprefixsoapisboundtotheSOAP1.1bindinginthisdocument.InsteadoftheSOAPbindingotherbindingsforJMSorafiletransportcanbeused.Theaddresselementhasoneattributenamedlocationpointingtoanendpointaddressoftheservice.

    Figure3:EndpointAddress

    Tomoveon,wehavetolookatthebindingattributeoftheport.Thevalue"tns:BLZServiceSOAP11Binding"pointstoabindingfurtherupinthedocument.Eachportispointingtoadifferentbindinginthisexample.AsaconsequencetheBLZServiceWSDLhasthreebindings.

    3

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 4/18

    Figure4:APortreferencesaBinding

    Abindingprovidesdetailsaboutaspecifictransport.Thebindinginfigure5hastwodifferenttypesofchildren.

    Figure5:SOAPBinding

    Firstwehavealookatthesoap:bindingelementinlisting3.ThevalueofthetransportattributeisanURIthatindicatesthatSOAPmessagesshouldbesendoverHTTP.Thevalue"document"ofthestyleattributegivesusaclueaboutthemessagestyletogetherwiththeuseattributeofthesoap:bodyelements.InourexamplewehaveaDocument/Literalmessagestyle.Abindingcanspecifydifferenttransportoptionsforeachmethodofaservice.

    1

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 5/18

    Listing3:SOAP1.1BindingLet'shavealookatlisting4.ThereyoucanfindtransportoptionsforthegetBankoperation.Insidethewsdl:operationelementthereisasoap:operationelementatline2definingdetailsfortheSOAPprotocolanditstransport.ThesoapActionisareminiscentfromthepast.TheBasicProfileoftheWebServicesInteroperabilityOrganizationstipulatesthatthesoapActionshouldbeusedwithafixedvalueofanemptystring.

    Listing4:BindingOperationBecauseWebServicessetthefocusonmessagesnotparameters,informationaboutthetransportofthesemessagescanbefoundinthewsdl:inputandwsdl:outputelement.Aservicemayspecifyoneorseveralfaultsasanalternativefortheoutput.

    23456789101112

    123456789

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 6/18

    Figure6:BindingOperation

    Thesoap:bodyandsoap:headerelementscandescribeamessagefurther.Intheexamplethestyleisalwaysliteral.

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 7/18

    Figure7:soap:bodyElements

    ItistimeagaintomoveupintheWSDL.Nowwefollowthevalueofthetypeattributeofthebinding.ItpointstoaportTypewiththesamenamefurtherupinthedocument.

    Figure8:BindingreferencingaPortType

    Nowwehavecrossedtheborderfromtheconcretedetailsaboutthetransportandlocationofaservicetoitspureabstractdescriptionofitsinterface.PortTypeisinWSDL1.1similartotheinterfaceoftheWebService.InWSDL2.0thetermportTypeissubstitutedwiththeterminterface.Aninterfacecanhaveseveraloperations.Anoperationcorrespondstoafunctioninproceduralprogramming.TheWSDLoftheBLZServicehasonlyoneportType.AllofthethreebindingsrefertotheoneportTypenamedBLZServicePortType.

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 8/18

    Figure9:OperationsofaportType

    InsideaportTypewefindoperationelementsasinthebinding.Butthistimetheinputandoutputdescribethestructureofthemessagesnottransportspecificoptions.

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 9/18

    Figure10:InputandOutputofanOperation

    ThemessageattributeoftheinputrefersagainupintheWSDLdocument.Itreferstoamessagenamedtns:getBank.Furtherupinthedocumentwefindacorrespondingmessagewiththisname.

    Listing5:TheInterfaceDescriptionoftheService

    123456

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 10/18

    Figure11:Message

    ThemessagegetBankhasonepartelementaschild.AWSDLspecialistwillrecognizethevalueoftheattributename,"parameters"indicatesthewrappersubstyleofthedocument/literalstyle.

    Listing6:getBankMessageTheattributeelementatline2pointsagainfurtherup.Itreferstoanelementnamedtns:getBank.WewillfindthiselementinaXMLSchema.

    123

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 11/18

    Figure12:AMessageanditsParts

    Thenextchildofthedefinitionselementistypes.

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 12/18

    Figure13:TheTypesSection

    ThetypeselementcanhavemultipleXMLschemasaschildren.

    Figure14:SchemasusedinaWSDL

    Listing7showsthetypeselementandanembeddedschema.

    1234567891011

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 13/18

    Listing7:EmbeddedXMLSchemaInaschemawecanfindthedefinitionof:

    complexTypessimpleTypes

    andthedeclerationof:elements

    TheXMLSchemainsideBLZServiceisatypicalschemausedforWebServicesthathasonlycomplexTypesandelementsastoplevelschemacomponents.Indocument/literalstyleallthepartspointtoelements.

    12131415161718192021222324

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 14/18

    Figure15:APartcanreferenceanElement

    Listing8showsthedeclarationofthegetBankelement.

    Listing8:DeclarationoftheElementgetBankThetypeofthiselementisacomplexTypenamedgetBankTypedefindedsomewhereelseintheschema.

    1

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 15/18

    Figure16:AnElementreferencesitsType

    ThegetBankTypehasasequenceasmodulgroupcontainingoneelementnamedblzofthebuildinschematypestring.

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 16/18

    Figure17:AComplexTypewithaSequenceasContent

    Listing9showsthedefinitionofthegetBankType.

    Listing9:TheComplexTypegetBankTypeAsequencecanconsistofseveralelementsthatdescribetheorderofelementsinaSOAPmessage.

    12345

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 17/18

    Figure18:TheentireStructureofaWSDLDocument

    FinallywearethroughtheentireWSDLdescriptionofthesampleservice.AllWSDLdocumentshavethesamestructureastheBLZService.TounderstandaWSDLstartreadingatthebottomandworkyourwayupbyfollowingtherightattributesasshowninthisarticle.IhopethisarticlewashelpfultolearnhowtoreadaWSDLdocument.

    [email protected]

    ReferencesWSDL1.1SpecificationWSDL2.0Specification

  • 14/06/2015 WSDLReading,aBeginner'sGuide

    http://predic8.com/wsdlreading.htm 18/18

    Copyright20082014predic8GmbHMoltkestr.40,53173Bonn,Tel.+49(228)55525760