Learning WebService, we can not leave the WSDL document, he is the basis of our development webservice, although, now there are many WebService open source framework allows us to generate client-side code based on WSDL, but it is necessary to understand the structure of the WSDL document. Gossip doesn't say much, we start to get to the chase.
First, let's look at a WSDL document.
This XML file does does appear to has any style information associated with it. The document tree is shown below.<!--Published by Jax-ws RI at http://jax-ws.dev.java.net. Ri ' s version is JAX-ws RI 2.2.4-B01. -<!--Generated by Jax-ws RI at http://jax-ws.dev.java.net. Ri ' s version is JAX-ws RI 2.2.4-B01. -<DefinitionsXMLNS:WSU= "Http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"xmlns:wsp= "Http://www.w3.org/ns/ws-policy"xmlns:wsp1_2= "Http://schemas.xmlsoap.org/ws/2004/09/policy"Xmlns:wsam= "Http://www.w3.org/2007/05/addressing/metadata"Xmlns:soap= "http://schemas.xmlsoap.org/wsdl/soap/"Xmlns:tns= "http://server/"xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"xmlns= "http://schemas.xmlsoap.org/wsdl/"targetnamespace= "http://server/"name= "Helloworldimplservice"><Types><Xsd:schema><Xsd:importnamespace= "http://server/"schemalocation= "Http://localhost:8989/HelloWorld?xsd=1"/></Xsd:schema></Types><messagename= "SayHello">< Partname= "Parameters"element= "Tns:sayhello"/></message><messagename= "Sayhelloresponse">< Partname= "Parameters"element= "Tns:sayhelloresponse"/></message><PortTypename= "Helloworldimpl"><Operationname= "SayHello"><inputwsam:action= "Http://server/HelloWorldImpl/sayHelloRequest"message= "Tns:sayhello"/><Outputwsam:action= "Http://server/HelloWorldImpl/sayHelloResponse"message= "Tns:sayhelloresponse"/></Operation></PortType><bindingname= "Helloworldimplportbinding"type= "Tns:helloworldimpl"><soap:bindingTransport= "Http://schemas.xmlsoap.org/soap/http"style= "Document"/><Operationname= "SayHello"><soap:operationSOAPAction=""/><input><Soap:body Use= "literal"/></input><Output><Soap:body Use= "literal"/></Output></Operation></binding><Servicename= "Helloworldimplservice"><Portname= "Helloworldimplport"binding= "Tns:helloworldimplportbinding"><soap:address Location= "Http://localhost:8989/HelloWorld"/></Port></Service></Definitions>
This document is my last article, I developed the webservice of the WSDL document, we today take him as an example to explain.
First, for a WSDL document, no matter how complex he is, it is made up of the following 5 elements.
<types> <message> <portType> <bingding> <service>
First of all, say, this <types> it defines the label structure, in the above WSDL document in the schema node content is
<xsd:import namespace= "http://server/" schemalocation= "http://localhost:8989/HelloWorld?xsd=1"/>
That means he has imported an XSD file that we can access in the browser, and the following will appear: schemalocation
This XML file does does appear to has any style information associated with it. The document tree is shown below.<!--Published by Jax-ws RI at http://jax-ws.dev.java.net. Ri ' s version is JAX-ws RI 2.2.4-B01. -<Xs:schemaXmlns:tns= "http://server/"Xmlns:xs= "Http://www.w3.org/2001/XMLSchema"version= "1.0"targetnamespace= "http://server/"><xs:elementname= "SayHello"type= "Tns:sayhello"/><xs:elementname= "Sayhelloresponse"type= "Tns:sayhelloresponse"/><Xs:complextypename= "SayHello"><xs:sequence><xs:elementname= "arg0"type= "Xs:string"minOccurs= "0"/></xs:sequence></Xs:complextype><Xs:complextypename= "Sayhelloresponse"><xs:sequence><xs:elementname= "return"type= "Xs:string"minOccurs= "0"/></xs:sequence></Xs:complextype></Xs:schema>
First he has an element called SayHello, and his structure should be like this.
<sayHello>
<arg0>string</arg0>
</sayHello>
Likewise, the element sayhelloresponse, his structure should be
<sayHelloResponse>
<return>string</return>
</sayHelloResponse>
The above file format is defined in <types>.
<message> structure SOAP message used to define the message, part: Specifies the label fragment defined in the reference types
<portType>
PortType: The SEI used to define the server side
Operation: The method used to specify processing requests in the SEI
Input: Specifies that the data passed by the client application will refer to the definition above for the
Output: Specifies that the server-side data returned to the client will refer to the defined
<bingding>
Binding: The implementation class used to define the SEI
Type attribute: Refer to <portType> above
<soap:binding style= "Document" >: bound data is a document (XML)
Operation: The method used to define the implementation
<soap:operation style= "Document"/> Transmission is document (XML)
Input: Specify the data that the client app passes over
<soap:body use= "literal"/>: Text data
Output: Specifies the data returned to the client by the server side
<soap:body use= "literal"/>: Text data
<service>
Service: A WebService container
Name property: It specifies the client container class with a
Port: The portal used to specify a server-side processing request (in the implementation of the SEI)
Binding properties: Refer to the <binding> defined above
Address: The current WebService request addresses
Understanding the element correspondence in the WSDL document, we can say that PortType is written in the server-side "dry", bingding is the client's "meat", service is to help clients to find this service side "dry" "meat."
WSDL Document parsing