To ensure compatibility between all users of SOAP. The libraries and toolkits that are used by developers have to follow the recommendations that are published by the W3C. And after the basic syntax of SOAP messages. One of the most important sets of recommendations has to do with what types of data you can encode in SOAP messages. You'll find that information on this web page, XML schema part two datatypes, this is for XML 1.2. SOAPs supports a large number of built in simple datatypes listed here under primitive datatypes.
They've include strings, booleans, a variety of numeric values. Date times and so on. A little bit further up into this document, you'll find a hierarchical tree describing how these data types related to each other. Now, fortunately you as a developer don't need to understand all of these details but the people who develop the SOAP toolkits do. And again, languages like Java that use static data typing. Will match up with the data types pretty closely, but other languages might have some translation to do.
Here are some examples of common data types used in SOAP. A string is just that, a series of alphanumeric characters. A SOAP based string doesn't have any length limit, but since the message is designed to be sent over the web. It's a good idea to deal mainly with shorter values, but really it can be anything. For simple numeric values you have a lot of choices. Short, longs, bytes and so on. Again, languages like Java that have similarly precise numeric data typing match up well with this list.
And what kind of messages can be sent and received. These documents are in XML and are very detailed, that they're usually generated automatically and read by SOAP toolkits. So don't let there complexity scare you off. This is a snippet of a WSDL document that describes three elements of a message. Each has a name and a data type. The XSD prefix would point to the XML schema's documentation that I referred to earlier.
These three elements are an integer, a string and another integer. SOAP also allows you to define complex objects. That is objects that have sets of predefined properties each of which has its own name and data type. These are the equivalent of an object oriented programming class Sometimes called a value object or a data transfer object. This is what the definition of a book object might look like with three string based properties. The element has a name of book and it's a complex type.
The complex type element is a part of the WSDL language. And then the three element within the complex type have their own names and data types. In this example, they're all strings. And this is an example of what that object might look like in a SOAP message. This is an instance of the book complex type And it has the three properties, author, preface, and intro. The namespace prefix e would point to the WSDL document that defined this service.
You can also use arrays, ordered sets of values where all values in the array are of a particular type. In the WSDL document, an array is defined as a complex type. In this example, it's given a name of array of float. The complex type has complex content and some restrictions. The restriction says that it's an array And the attribute array type says that the values in the array are floats. Then, typically in the same WSDL document, a data element known as a message part would be declared that uses that type.
So, the name of this message is GetTradePricesOutput and it has a part which is of a data type ArrayOfFloat. When the data is encoded in a SOAP message, it'll have the name that's specified in they WSDL document. In this case, get trade prices output. And then the data, which might be listed like this. The goal of SOAP and WSDL encoding is to be infinitely flexible as to what types of data need to be transmitted. Unlike older web service formats, which typically were designed to represent only a predesigned set of data types.
SOAP can represent pretty much anything your software needs. As we'll see in the next movie. The Web Services Description Language or WSDL can represent whatever your application is making available to the web service client. And you don't have to encode the WSDL document or the SOAP messages yourself. It's all done for you by the software we call SOAP toolkits.
- What is a web service?
- Understanding the available transfer protocols and message formats
- Examining SOAP request and response formats
- Creating a simple SOAP service in ASP.NET
- Choosing a SOAP implementation
- Associating REST actions with HTTP requests
- Sending RESTful requests
- Creating OData request URIs
- Securing web services