ReferenceArticle:
Http://www.cnblogs.com/hoojo/archive/2010/12/20/1911363.html
If you first know that axis releases/calls WS, we recommend that you read the reference file above. The main steps for publishing/calling ws in this article are simple text descriptions, but they are not described in detail;
The difference between this example and the reference document is as follows:
1) Deploy. WSDD ):
< Deployment Xmlns = "Http://xml.apache.org/axis/wsdd" Xmlns: Java = "Http://xml.apache.org/axis/wsdd/providers/java" > < Service Name = "Calculate" Provider = "Java: RPC" Style = "RPC" Use = "Literal" > < Parameter Name = "Wsdltargetnamespace" Value = "Http://web.webservice.CalculateService.org" /> < Parameter Name = "Wsdlserviceelement" Value = "Calculate" /> < Parameter Name = "Wsdlserviceport" Value = "Calculateservice" /> < Parameter Name = "Wsdlporttype" Value = "Icalculate" /> < Parameter Name = "Classname" Value = "Org. calculateservice. Service. calculateimp" /> < Parameter Name = "Typemappingversion" Value = "1.2" /> < Parameter Name = "Allowedmethods" Value = "Add sub" /> < Parameter Name = "Scope" Value = "Request" /> < Operation Name = "Add" QNAME = "Operns: Add" Xmlns: operns = "Http://web.webservice.CalculateService.org" Returnqname = "Addreturn" Returntype = "RTNs: int" Xmlns: RTNs = "Http://www.w3.org/2001/XMLSchema" Soapaction = "" > < Parameter QNAME = "X" Type = "TNS: int" Xmlns: TNS = "Http://www.w3.org/2001/XMLSchema" /> < Parameter QNAME = "Y" Type = "TNS: int" Xmlns: TNS = "Http://www.w3.org/2001/XMLSchema" /> </ Operation > < Operation Name = "Sub" QNAME = "Operns: Sub" Xmlns: operns = "Http://web.webservice.CalculateService.org" Returnqname = "Subreturn" Returntype = "RTNs: int" Xmlns: RTNs = "Http://www.w3.org/2001/XMLSchema" Soapaction = "" > < Parameter QNAME = "X" Type = "TNS: int" Xmlns: TNS = "Http://www.w3.org/2001/XMLSchema" /> < Parameter QNAME = "Y" Type = "TNS: int" Xmlns: TNS = "Http://www.w3.org/2001/XMLSchema" /> </ Operation > </ Service > </ Deployment >
2) custom axisservlet: org. calculateservice. Core. axisservlet (compatible with. NET and removed the soapaction test );
DetailsCodeI will not post it here. I am interested in downloading the complete sample code;
3) The call method is local class call (Java ws call seems to have three methods, and I personally feel that local proxy class calls are the most reasonable and readable ):
Public Static VoidMain (string [] ARGs)ThrowsServiceexception, RemoteException {calculate=NewCalculatelocator ();IntResult = calculate. getcalculateservice (). Add (1, 2); System. Out. println ("[% 1 + 2 =" + Result + "%]");}
Steps for publishing/calling WS:
1) copy the axis directory of the webapp in the axis1.4 installation package from the downloaded resource to the webapp directory in Tomcat;
2) write the WS server implementation code;
3) Write deploy. WSDD deployment file in the WEB-INF directory;
4) Write: generate-server-config.bat script, and then generate: server-config.wsdd, and then publish WebService;
5) write the wsdl2java. Bat script to generate the local client code;
6) Compile the test code to call ws;
Code structure:
Client: Use wsdl2java to generate local client code based on WSDL;
Core: Custom axisservlet, compatible with. net, removes the soapaction test;
Service: Ws server implementation code (Here we use a simple addition and subtraction calculation as an instance );
Test: call server according to the generated client class (the generated code server address is localhost. If you need to change this address to configuration, modify the value of the variable calculateservice_address in the calculatelocator class );
Complete example:
Http://download.csdn.net/detail/camelials/5144441
The resource contains the complete sample code and the axis1.4 Installation File.