Java Engineering uses axis stub to generate WebService client code

Source: Internet
Author: User
Tags wsdl

Axis2 provides a wsdl2java.bat command to automatically generate calls based on the WSDL file WebService The code. the Wsdl2java.bat command can be found in the <axis2 installation directory >/bin directory.

in use wsdl2java.bat command to set axis2_home environment variable, the variable value is <axis2 installation directory > windows The console outputs the following command line to generate a call to webservice code:

%axis2_home%\bin\wsdl2java-uri [WSDL] - p client-s-o stub

Example:%axis2_home%\bin\wsdl2java-urihttp://localhost:8080/Hikvision/services/myWebservice?wsdl- p Client-s-o stub

after you finish executing the above command , you will find in the current directory (i.e. <axis2 installation directory >/bin below) stub directory, &NBSP; stub/src/client directory can find a xxxstub.java file, complex call to webservice

Call Method:

1. In the new Java project, import the client package from the stub directory just generated into the SRC directory of the project and import the jar package required in axis in the Lib directory (otherwise it will be an error).

2. Calling Methods in programs

Package Com.hcj.webservice;import client. Mywebservicestub;import client. Mywebservicestub.getalluserresponse;public class Test {public static void main (string[] args) throws Exception {// Create the generated stub class mywebservicestub stub = new Mywebservicestub ();//Create the corresponding method class (here I have a getalluser method in my WebService, Specifically, see what method you define in your own webservice) Getalluserresponse AllUser = Stub.getalluser ();//Gets the result set of the method class string Get_return = Alluser.get_ return ();//printout result System.out.println (Get_return);}}

Java Engineering uses axis stubs to generate WebService client code

Related Article

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.