The difference between this example and the reference article is:
1 DEPLOY.WSDD defined more detailed (interface defined for server side: icalculate):
Copy Code code as follows:
<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 to remove the SOAPAction test);
Detailed code is not posted here, interested in downloading the complete sample code;
3 The invocation method is called with the local class (Java invoke WS seems to have three ways, the personal feeling is most reasonable and readable by the local proxy class):
Copy Code code as follows:
public static void Main (string[] args) throws Serviceexception, RemoteException {
Calculate Calculate = new Calculatelocator ();
int result = Calculate.getcalculateservice (). Add (1, 2);
System.out.println ("[%1 + 2 =" + result + "%]");
}
main steps to publish/Invoke WS:
1 Copy the Axis directory in the WebApp in the axis1.4 installation package in the download resource to the WebApp directory in Tomcat;
2 Write WS-Server implementation code;
(3) Writing DEPLOY.WSDD deployment files in the Web-inf directory;
4 Write: Generate-server-config.bat script, then generate: SERVER-CONFIG.WSDD, then release WebService;
5 Write: Wsdl2java.bat script cost to invoke client code;
6 write test code call WS;
Code structure diagram:
client: generates local client code with Wsdl2java based on WSDL;
Core: custom Axisservlet, compatible with. NET removes the SOAPAction test;
Service: WS-Server implementation code (here with a simple addition and subtraction calculation as an example);
Test: Call the server based on the generated client class (the generated code server address is localhost, and if you need to change this address to configuration, modify the variable in the Calculatelocator class Calculateservice_ Address assigned value can be);
Click to download the full sample
The resource contains sample complete code and axis1.4 installation files