Web Service 2 Development: WSDL reverse generation server

Source: Internet
Author: User
Tags wsdl

Generally, the Web Service is developed by selecting the write server and then generating the client based on the generated WSDL file. I have read an SOA book saying that if the implementation prevents incompatibility between some specific data types in different languages, we recommend that you first define the WSDL interface, it includes an input/output parameter, return value, and related data types, and then uses WSDL to generate the server and client. The advantage is that the server does not need to care about how the client calls them, the client does not need to be implemented on the server.

For details about how to configure axis2 in eclipse, refer to my simple computing service example. Here we will create a new WSDL file, for example:

Change the name to "manager. WSDL", for example:

Next, define the namespace, protocol, and other information, which is the row by default. For example:

After finishing, the following will appear in the main Workspace:

This is a graphical form of manager. WSDL. Click "Source" to view the source code:

This is the default generated WSDL. We need to modify the above figure according to the needs of our project. First, modify the method name of the other party, for example:

It can be seen that after the modification, the input and output on the right are also modified. The two are the input and output of the plus definition.

Click the prompt arrow on the right of the input parameter "plus" to go:

Here we define the input parameters and parameter types. Because our plus (float X, float y) method has two parameters X and Y, we will change them to the sequence of two parameters:

In other words, comparing the plus (float X, float y) method is not too difficult to understand!

Return to the manager. WSDL view and select the arrow on the right of the output parameter to go:

Here we set the return value and type of the float plus (float X, float y) method, because there is only one return value, we only need to change the above out type to the float used in our method. After the change, for example:

Have you noticed that there is an icon in the upper left corner? Click it to enter:

Here, we can modify the input and output parameters and other data types. If additional labels are accidentally generated during the above operation, we can also remove them here.

Now, let's go back to manager. WSDL and right-click the source code view and select "Validate" to check the XML document. If any error occurs, modify it as needed.

Well, the WSDL document compiled in graphical form is complete. By the way, multiple methods can be defined, such:

For the sake of simplicity, let's take the defined method as an example to see how to automatically generate the Web Service Server Based on the WSDL file.

 

We have a new Web service, such:

Remember to select "Top down Java Bean Web Service" in Web service type, for example:

Then, find the manager. WSDL file you just wrote in service definition.

Return to the Web Service dialog box and adjust the service type slider to "develop service,

Next, click Next-> next --> finish. It will automatically generate the Web Service server interface and Class. in the class, you can find the method we defined:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We only need to modify the method body of method plus to implement the functions that we want to implement. As follows:

This is the simplest example of generating a Web Service server through WSDL in reverse direction. It may not be helpful. It is not like [graphic tutorial] One of the Web Services integrated by axis2 and Eclipse: simple computing service examples are as simple and convenient as possible. However, for some specific data types, such as list and set, we can find the corresponding alternative types in the WSDL graphic design, define the WSDL and then generate the server interface. In this way, not only is there no problem with the Java Development client, but with the C # development client, there is no error!

However, if you first develop the server, if you use some java-specific data types, such as list and set, if you use Clients generated in other languages, problems may occur. Similarly, if C # is used to develop the server, if a return type such as dataset is used, the problem may also occur if the client is developed in Java or other languages.

If you write the WSDL first, and then generate the server and client based on the WSDL, it should be a good practice. Eclipse's graphical support in this aspect will give us a multiplier effect, it is also in line with SOA practices.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.