Using the MyEclipse plugin to generate Java client code for WSDL

Source: Internet
Author: User
Tags soap wsdl

Usage Environment: MyEclipse9.0

This tutorial uses the MyEclipse built-in plug-in to generate Java code, which is said to be a xfire plug-in, anyway, it is very simple to generate and invoke client code.

1. Right-click on the project and select New->other->web service->web Service client->next to see the following interface:

Here you can select the WSDL file, or write the URL address of the WSDL, it is recommended to write the URL, so that the call does not need to modify the generated code. Then use the default settings all the way next, last finish.

2. Calling the procedure

After generating the code, you will find that SRC has more than one package, and the name of the package is related to the namespace of the Web service.

We can look at the Java file named after the name PortType in WSDL, this is Service1soap.java, which is an interface that contains all the methods in the Web service.

Let's start with the call procedure, take the Add method above as an example, start with a new Service1 object, then create a Service1Soap object from the service object, and finally call the desired method, with the following code:

[Java]View PlainCopy print?
    1. Service1 service = new Service1 ();
    2. Service1Soap soap = Service.getservice1soap ();
    3. System.out.println (Soap.add (3, 4));

PS: Using this plugin can also check the correctness of the WSDL, you can open a WSDL file by using MyEclipse, if the file does not conform to the WSDL specification, the left side will appear warning. In addition, during the creation of the Web service client, the plug-in also validate the WSDL file, and if there is an error, no code is generated. Note: The plug-in error will have the wrong code, this is the WSDL rule, you can view the error code on http://ws-i.org/profiles/basicprofile-2.0-2010-11-09.html.

Using the MyEclipse plugin to generate Java client code for WSDL

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.