Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

Services Defined in WSDL

In WSDL, a service element is used to group together port elements, the elements that directly address the protocols on which an XML Web service will communicate. The service element contains a name attribute, line 1 of Listing 3.2, which is set to the actual name of the XML Web service that the service element represents.

Within each service element may be a documentation element and one or more port elements. The documentation element, lines 2 and 3, will contain comment information about the XML Web service.

The port elements will contain two attributes of their own, name and binding. The name element provides a unique identifier for each port element within a service. This name is typically created by adding the name of the port's protocol, SOAP in line 4, to the end of the service's name. The binding element points to the actual portType element, which you will study in a later section.

Also contained within the port element is the address element. This element points to the actual URL address that client applications will use to contact an XML Web service via the given port. You will notice that the example in Listing 3.2 gives the same address for all three ports. This is typically the case when creating services with Visual Studio .NET, but WSDL allows for developers to create services that utilize different addresses to handle the various port communications.

Listing 3.2 Services Defined in WSDL

1:  <service name="DataTypes">
2:   <documentation>test of using various data types in
3:            XML Web Services</documentation>
4:   <port name="DataTypesSoap" binding="s0:DataTypesSoap">
5:    <soap:address location="http://localhost/DataTypes/Service1.asmx" />
6:   </port>
7:   <port name="DataTypesHttpGet" binding="s0:DataTypesHttpGet">
8:    <http:address location="http://localhost/DataTypes/Service1.asmx" />
9:   </port>
10:  <port name="DataTypesHttpPost" binding="s0:DataTypesHttpPost">
11:   <http:address location="http://localhost/DataTypes/Service1.asmx" />
12:  </port>
13: </service>
  • + Share This
  • 🔖 Save To Your Account