Author Bilal Siddiqui (WAP_MONSTER@yahoo.com) CEO, WAP MONSTER01 NOV 2001
Translator: Mei Qingsong
Note: Due to time and my own level, errors are inevitable, but also hope.
Summary:
This article describes the main technologies for creation, configuration, and release Web Service: From Web Services Markup Language (WSDL), Simple Object Access Protocol (SOAP), to Universal Description Discovery and Integration (UDDI) registration. This section will learn how to manually create a WSDL interface.
The idea of web-based distributed interactive application software has long been there, and the electronic data exchange has appeared before the B2B e-commerce has received. With the popularity of the B2B market, interaction capabilities become the most important requirements for data exchange.
All online electrical business has a lot of business services, each with its own service (called Web Service). Today's e-commerce has no mechanism for automatically discovering a business service of its potential partners. The network called the next generation will provide this automatic discovery function.
One. What is WSDL
The next generation of networks require a solution that describes the details of the service (Web Service), which means that you need a format or some syntax you can use to describe the answers to the following questions:
● What services have your online trading provide?
● How to call your service?
● What information do you need for users when users call your service?
● How do users provide information you want?
● What is the format of the service will return to the user?
It is worthy of WSDL to provide mechanisms for doing these things.
two. WSDL and SOAP
In order to better understand how WSDL work, I will first describe how SOAP and HTTP work with WSDL. WSDL is used to describe the Web Service. Due to the exchange of WSDL files between transactions. Use SOAP when you understand and use partners' services. You can regard the services accessed through SOAP as objects.
It is very likely that you communicate with an internet or email and potential partners. The Internet uses HTTP, email uses SMTP to make HTTP and SMTP a SOAP optimal transmission service carrier.
three. WSDL writing
Here is how to write WSDL for Web Service. The purpose of writing WSDL is to publish the existing Web Service. You may be in one of the following situations
● You already have a service ready to release it.
● You have WSDL to implement Web services based on the feature that is prepared in WSDL. (Some people think this is unlikely. But UDDI fingerprint technology makes it possible.)
● You are not ready to start doing.
four. Write four steps from WSDL:
I will divide WSDL into four simple steps. Step by step to do your web service can be released.
1. Service interface
We will create a simple mobile phone retail store (I will call it MobilPhoneService) as an example. This company sells several different models of mobile phones, so the web service's backend database has only one piece with two fields - Modal Number, Price. Two methods you will release your service via WSDL:
● getListofmodels ()
● getprice (modelnumber)
The getListofmodels method returns a string array containing the mobile phone model. The getprice method is based on the model query price. WSDL will be called these methods. You can now create a WSDL interface file.
The root node of the WSDL file is
The
Each service must have a name. In this example, we have only one service, so we must name our mobile phone sales service using the Name property of the PortType node.
Each service can contain multiple methods (or operations), with
The WSDL file at this time is as shown below:
Listing 1: Defining Operations
Xml version = "1.0" encoding = "UTF-8"?>
After the operation (or method) is defined, we need to specify the parameters of the incoming operation and the return parameter of the operation. In WSDL, all parameters are called messages. This helps us send an operational imagination to send a message to us then get the return message.
Method call is a process of receiving messages and then returning a result message.
Back to the first step, we have two operations that need to be released. The first operation getListofmodels does not have a parameter to return a character string of the Han mobile phone model. Therefore, we define a
In Figure Listing 2 we can see there are several
There is also a TYPE attribute in the
We take the number of strings returned by GetListofmodels as an example to explain why you want to create a nameshe you created. WSDL uses the simple data type defined by XML Schema Definition (XSD). In the message, you can use these simple data types directly, or use the complex types of these data type components. This is why you must define your namespace when you use complex types. In this example you need to define a complex type for the string array. You can use XSD to create your own namespace. So we must use the XSD: ComplexType element in the
In Figure Listing 2, I also defined two other messages: PhoneModel and PhoneModelprice. These two messages use the simple data type under the XSD namespace, so there is no need to define complex types.
You may have noticed that no specified parameters are incoming parameters or return values without specifying parameters when creating
Listing 2: Defining Parameters
XML Version = "1.0" encoding = "UTF-8"?>
I am abstracting operations and messages, but there is no detail that it is implemented. In fact, WSDL is used to define and describe the Web Service to facilitate a reference for the external frame to define how the WSDL user reaches these services. You can regard the framework as an abstract definition of WSDL and a binding of implementation.
The current most popular binding technology is to use Simple Object Access Protocol (SOAP) .WSDL will detail the implementation of the SOAP that can access your service, and later the SOAP is responsible for connecting users from the WSDL file to the WSDL implementation. SOAP will be the next topic of my article, so I will avoid introducing the details of SOAP to facilitate WSDL writing.
A third step by writing WSDL is to describe how to bind SOAP to a WSDL file. You need to join the
WSDL's binding nodes contain a declaration of external technologies used in binding. Since you use SOAP, you will use SOAP namespace. The use of WSDL is in that the use of external namespace is referred to as an extensibility Element.
In Figure Listing 3, you can see an empty binding node (
The SOAP client reads the SOAP structure from the WSDL file to synchronize with the SOAP service, so you must pay attention to the ability of collaborative work. The details I will tell in the third part of this series.
There are two WSDL
In the second step, the getListofmodels operates only the output is not input, so you must provide a
You will end the third step. Just copy the next operation, you will follow the picture Listing 3. Listing 3: Added SOAP Support
XML Version = "1.0" encoding = "UTF-8"?>
operation name = "getPrice">
definitions> 4. to sum up
You have completed a full-description of the WSDL file for the interface of your service. WSDL also requires a summary for the WSDL file. WSDL is called execution file. This execution file is required when you use UDDI registration (will introduce the fourth part of this series). Figure Listing 4 is a WSDL execution file. Its main characteristics are as follows:
● Root nodes
● Interface files (Listing 3) and its namespaces are referenced in the
● There is a
Listing 4: WSDL IMPLEMENTATION FILE
XML Version = "1.0" encoding = "uTF-8"?>
Fives. Wuse WSDL using IBM's Web Service tool
This web service can be released. I have already demonstrated how to create these files manually. These files can also use the Web Service writing tool such as IBM WSTK generation.
WSTK can build these files by wizard. Users can generate the WSDL files of the two methods that I present above, compare the difference between the two. You will find the following differences:
● WSTK uses logical rules to create all name properties, and I define names as needed in the example.
● WSTK generates at least one INPUT tag for each operation, even if the operation does not have any input. Just like the ListAllPhoneModels operation is not entered, but if you use WSTK to generate a WSDL file, you will contain an empty INPUT node.
● WSTK will generate a third file outside of these two files. The third file is a SOAP release descriptor, and the SOAP engine is used when the service is published.
In this section, I demonstrated manually created WSDL interfaces and execute files and compared to files generated with IBM's WSTK tools. In the next part of this series, I will discuss this WSDL service to the SOAP service.
Original link: http://www-106.ibm.com/developerWorks/library/ws-intwsdl/#h2