Build a Web service server/client using Eclipse's own Web service plug-in (Axis1.4)

Source: Internet
Author: User
Tags web services java web wsdl

JDK version: 1.5.0_22

Eclipse version: Helios Service Release 2 (3.6.2)

The WSDL file creation process is shown in http://blog.csdn.net/a19881029/article/details/24625429

Create a Java Web project named Math and copy the WSDL file into the project

The jar packages required by axis are copied to the Webroot\web-inf\lib directory, which is automatically imported into the math project

one, generate the Web service server side

Select mathimpl.wsdl file Right-click->web services->generate Java Bean Skeleton

Just generate the Web service server-side code, choose the Tomcat 6.0,web service environment Select Apache Axis, service Engineering Select Math Project, select Finish and click "Next":

Then select the Web Servic server-side code generation path, select Finish and click "Next":

Generate only Web service server-side code and not deploy it, just click "Done" here

At this point, you can see that the code and deployment/release files for the Web service server are automatically generated in the math project

Just write the server-side specific process in the Mathimplsoapbindingimpl file:[Java]  View plain copy/**   * MathImplSoapBindingImpl.java   *   * this  file was auto-generated from WSDL   * by the Apache  axis 1.4 apr 22, 2006  (06:55:48 PDT)  WSDL2Java emitter.   */       package com.sean.ws;      public class  mathimplsoapbindingimpl implements com.sean.ws.mathimpl{       public  int plus (int a, int b)  throws java.rmi.RemoteException {           //return -3;            int c = a + b;            system.out.println ("The result is:"  + c);            return c;       }  }  

two, generate the Web service client

Select mathimpl.wsdl file Right-click->web services->generate Client

To generate only the Web service client code, select Finish and click Next:

Then select the Web Servic client code generation path, select Done and click "Finish":

At this point, you can see that the Web service client code is automatically generated in the math project

Use the Mathimplproxy class directly: [Java] view plain copy package com.sean.ws;      Import java.rmi.RemoteException; public class Test {public static void main (string[] args) throws RemoteException {Mathimplproxy proxy =           New Mathimplproxy ();       Proxy.plus (1, 2); }   }

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.