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); } }