Java comes with wsimport to generate WebService client code

Source: Internet
Author: User

In the binfile folder of JDK, there is a wsimport.exe. This tool generates corresponding class files based on the WSDL file, and then uses these class files to call WebService providers like calling local classes. This tool can be used on non-Java servers, such as WebService written in C #. Java client implementation is generated through wsimport.

Run the following command in the command prompt: wsimport-keep-P com. Demo. Client http: // localhost: 8080/demo/services/myservice? WSDL

Command parameter description:-D: directory where class files of the client execution class are generated-S: directory where source files of the client execution class are stored-P: to define the package name of the build class, see: After the http://download-llnw.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html uses the wsimport command, we can get the following Code File: Current directory in the command line | -- Com | -- demo | -- client | -- Example. java | -- exampleresponse. java | -- myservice. java | -- myserviceporttype. java | -- objectfactory. java | -- The package-info.java can copy the above file to your project and use it. Test: Create a project, copy the com. Demo. Client package to the project file, and write the test. Java file. The Code is as follows: Package com. Demo. wsimport;

Public class test {

/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Myservice Server = new myservice ();
Myserviceporttype SPT = server. getmyservicehttpport ();
System. Out. println (SPT. Example ("hello "));
}
}

In the binfile folder of JDK, there is a wsimport.exe. This tool generates corresponding class files based on the WSDL file, and then uses these class files to call WebService providers like calling local classes. This tool can be used on non-Java servers, such as WebService written in C #. Java client implementation is generated through wsimport.

Run the following command in the command prompt: wsimport-keep-P com. Demo. Client http: // localhost: 8080/demo/services/myservice? WSDL

Command parameter description:-D: directory where class files of the client execution class are generated-S: directory where source files of the client execution class are stored-P: to define the package name of the build class, see the following code file after the http://download-llnw.oracle.com/javase/6/docs/technotes/tools/share/wsimport.html uses the wsimport command: Current directory in the command line | -- Com | -- demo | -- client | -- Example. java | -- exampleresponse. java | -- myservice. java | -- myserviceporttype. java | -- objectfactory. java | -- The package-info.java can copy the above file to your project and use it. Test: Create a project, copy the com. Demo. Client package to the project file, and write the test. Java file. The Code is as follows: Package com. Demo. wsimport;

Public class test {

/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Myservice Server = new myservice ();
Myserviceporttype SPT = server. getmyservicehttpport ();
System. Out. println (SPT. Example ("hello "));
}
}

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.