Upgrade to JDK 5.0 Update 1 or 2 custom deployment WebServices - Axis is finally normal!
JDK 1.4.x is normal! But JDK 5.0 customs to deploy WebServices - Axis, execute the command line: java org.apache.axis.client.adminClient deploy.WSDD is always abnormal! Upgrade to Update 1: Java Version "1.5.0_01 "Java (TM) 2 Runtime Environment, Standard Edition (Build 1.5.0_01-B08) Java Hotspot (TM) Client VM (Build 1.5.0_01-B08, Mixed Mode, Sharing) Finally! Related Download:
JDK 5.0 Update 1: http://dlc.sun.com/jdk/jdk-1_5_0_01-windows-i586-p.exe
Resin 2.1.16 (recommended, because relative to Tomcat is small) http://www.caucho.com/download/resin-2.1.16.zip
Tomcat 5.5.7http: //apache.justdn.org/jakarta/tomcat-5/v5.5.7/bin/jakarta-tomcat-5.5.7.zip
Apache WebServices - Axis V1.1: (June 16, 2003) http://apache.freeelamp.com/ws/axis/1_1/AXIS-1_1.Zip After decompression, the Axis directory under the AXIS-1_1 / WebApps / directory Copy to RESIN or TOMCAT's webapps directory!
JavaMail API 1.3.2 FCS: http: //192.18.97.52/ECom/EComTicketServlet/BEGIN0C28A9F726724B9DD60F1DA518A6C32A/-2147483648/755528103/1/540782/540770/755528103/2ts /westCoastFSEND/javamail-1_3_2-oth-JPR/javamail-1_3_2- OTH-JPR: 1 / JavaMail-1_3_2.zip
JavaBeans (TM) Activation Framework 1.0.2: http: //192.18.97.131/ECom/EComTicketServlet/BEGIN145B389A284A19AC4F88E80C4CFBA0D3/-2147483648/755539779/1/359918/359906/755539779/2ts /westCoastFSEND/7017-jaf-1.0.2-oth -JPR / 7017-JAF-1.0.2-OTH-JPR: 1 / JAF 1_0_2-UPD.zip
XML Security Version 1.2 of the java library: http://xml.apache.org/security/dist/java-library/xml-security-bin-1_2_0.zip
Listing: activation.jaraxis-ant.jaraxis.jarcommons-discovery.jarcommons-logging-api.jarcommons-logging.jarjaxrpc.jarlog4j-1.2.8.jarmail.jarsaaj.jarstylebook-1.0-b3_xalan-2.jarwsdl4j.jarxalan.jarxercesImpl. JARXML-APIS.JARXMLPARSERAPIS.JARXMLSEC.JARXMLSECSMPLES.JARXMLSECTESTS.JAR
Class1.java file Save to /Webapps/Axis/web-inf/classes/class1.java execution: Javac class1.java compiled into class1.class: public class class1 {public static void main () {system.out.println (" Hello world! "); //System.out.println (new jwsclass1 (). Saylloto (" world! "));} Public string sayhelloto (String who) {return" Hello: " who;} public string self Sayllotoo (String who) {return "Hello:" WHO;}} http: // localhost: 1080 / axis / services / class1service? WSDL Save As: Xx.wsdlDeploy.wsdd (undeploy.wsdd) file, deploy.wsdd ( Undeploy.wsdd) Deployment File
Client:
(a) Generate the client memory (STUB) code, the server frame (SKELETON) code, and the data type file in WSDL (generated Java code) can be generated by the command line :: java org.apache.axis .wsdl.wsdl2java --skeletondeploy true xx.wsdl
1. deploy.wsdd: MyService deployment descriptors service 2. MyService.java: MyService service interface file 3. MyServiceService.java: obtaining service interface file MyService 4. MyServiceServiceLocator.java: MyServiceService implement the interface 5. MyServiceSoapBindingImpl.java: Implement the MyService interface, you should supplement the service logic 6. MyServiceSoapBindingskeleton.java: MyService service server frame code, implement myService, org.apache.axis.wsdl.skeleton interface 7. MyServiceSoapBindingstub.java: MyService service client memory root code Implement the MyService interface 8. Undeploy.wsdd: Logout Description File for the MyService service
(b) Dynamic calls WebServices: See: Wang Wei Gang WSCaller: Web Service General Client and Test Tool http://www.contextfree.net/wangyg/c/wscaller/wscaller.html
import org.apache.axis.Constants; import org.apache.axis.encoding.ser.SimpleDeserializer; import org.apache.axis.wsdl.gen.Parser; import org.apache.axis.wsdl.symbolTable *;. import javax .wsdl. *; // Import javax.wsdl.extensions.soap.soapaddress; import javax.xml.namespace.qname; import javax.xml.rpc.call; import javax.xml.rpc.encoding.deSerializer; import javax. Xml.rpc.encoding.deserializerfactory;
Import java.util. *;
// Import localhost.axis.services; // Web Service Dynamic Invoker
Public Class Dynamicinvoker {Private Parser WSDLPARSER = NULL; Private Map Services = NULL;
Public Dynamicinvoker (String WSDLURL) THROWS Exception {WsdlParser = New Parser (); WSDLPARSER.RUN (WSDLURL); Services = Enumsymtabentry (ServiceEntry.class);}
Public Map Invoke (String ServiceName, String PortName, String Operationname, Vector ParameterValues) throws Exception {Vector Inputs = New Vector (); string returnname = NULL
ServiceEntry serviceEntry = (ServiceEntry) services.get (serviceName); Service service = serviceEntry.getService (); org.apache.axis.client.Service clientService = new org.apache.axis.client.Service (wsdlParser, service.getQName ( ));
Call call = clientService.createCall (QName.Valueof (OperationName)); (org.apache.axis.client.call) .SetTimeout (New Integer (15 * 1000));
Bindingentry bindingentry = getBindingNGentry; Operation O = getoperation (bindingentry, Operationname); parameters parameters = bindingentry.getParameters (O);
if (parameters.returnParam = null!) {// QName returnType = org.apache.axis.wsdl.toJava.Utils.getXSIType (parameters.returnParam); QName returnQName = parameters.returnParam.getQName (); returnName = returnQName.getLocalPart (); Int size = parameters.list.size (); for (int i = 0; i Object ret = call.invoke (Inputs.toArray ()); map outputs = call.getOutputParams (); hashmap map = new hashmap (); if (ret! = Null && returnname! = Null) {map.put (ReturnName, RET);}}} (outputs! = null) {for (Iterator i = Outputs.keyset (). Iterator (); I.hasNext ();) {Object Obj = i.next (); string name; Object value; IF (Obj.getClass (). getName (). Equals ("java.lang.string")) {name = (String) Obj;} else {name = ((qname) obj) .getlocalpart ();} value = Outputs.get (obj); map.put (name, value);}}}}}}}}}}} Return Map; Public Vector EnumServiceNames () {Vector V = New Vector (); Iterator i = Services.KeySet (). Iterator (); while (I.hasNext ()) {string s = (String) i.next (); v. Addelement (s);} Return V; public Vector enumPortNames (String serviceName) {Vector v = new Vector (); ServiceEntry serviceEntry = (ServiceEntry) services.get (serviceName); Map ports = serviceEntry.getService () getPorts ();. Iterator i = ports.keySet () .iterator (); while (I.hasNext ()) {string s = (String) i.next (); v.addelement (s);} return v;} public vector enumopertyNames (String ServiceName) (String portname) {Vector v = new vector (); bindingentry entry = getBindINGENTRY (ServiceName, portname); set Operations = entry.getOperations (); item i = Operations.iterator (); while (I.hasNext ()) {Operation O = (Operation) I.next (); string s = o.getname (); v.addelement (s);} returnv; public Parameters enumParameters (String serviceName, String portName, String operationName) {BindingEntry entry = getBindingEntry (serviceName, portName); Operation o = getOperation (entry, operationName); Parameters parameters = entry.getParameters (o); return parameters;} Public String getParameterModestring (parameter p) {string ret = null; switch (p.getmode ()) {copy parameter.in: ret = "[in]"; break; case parameter.inout: ret = "[in, out] "; Break; case parameter.out: Ret =" [out] "; Break;} Return Ret; private BindingEntry getBindingEntry (String serviceName, String portName) {ServiceEntry serviceEntry = (ServiceEntry) services.get (serviceName);. Port port = serviceEntry.getService () getPort (portName); Binding binding = port.getBinding (); SymbolTable table = WSDLPARSER.GETSYMBOLTABLE (); return table.getbindingentry (binding.getqname ());} Private Operation Getoperation (bindingentry entry, string operationname) {set Operations = entry.getOperations (); item i = Operations.Iterator (); while (i.hasnext ()) {Operation O = (Operation) i.next (); if (operationName.equals (o.getName ())) {return o;}} return null;} // return Map of private Object getParamData (org.apache.axis.client.Call c, Parameter p, String arg) throws Exception {// Get the QName representing the parameter type QName paramType = org.apache.axis.wsdl.toJava.Utils.getXSIType ( p); TypeEntry type = p.getType (); if (type instanceof BaseType && ((BaseType) type) .isBaseType ()) {DeserializerFactory factory = c.getTypeMapping () getDeserializer (paramType);. Deserializer deserializer = factory.getDeserializerAs (Constants. AXIS_SAX); if (deserializer instanceof SimpleDeserializer) {return ((SimpleDeserializer) deserializer) .makeValue (arg);}} throw new RuntimeException ( "not know how to convert '" arg "' into" c);}} Class Apptest {public static void main (string [] args) throws exception {system.out.println ("Hello World!"); // Dynamic call WebServics string location = "http: // localhost: 1080 / axis / service ? Class1Service wsdl "; DynamicInvoker invoker = new DynamicInvoker (location); Vector vServices = invoker.enumServiceNames (); Object [] Services = vServices.toArray (); Arrays.sort (Services); for (int i = 0; i < Services.Length; I ) {string serviceName = (string) services [i]; system.out.println; Vector v = invoker.enumportNames (service); string portname = (string) v.Elementat (0); V = invoker.enumOperationNames (serviceName, portName); Object [] OperationNames = V.toArray (); Arrays.sort (OperationNames); for (int j = 0; j Invoker.invoke (ServiceName, PortName, Operationname); for (iTerator it = Result.keyset (). iterator (); it.hasnext ();) {string name = (string) it.next (); Object Value = Result.get (name); String line; if (value! = null) {line = name "=" result.get (name) .tostring () "/ n";} else {line = name "= (null) / n";} system.out.println (line);}}} // call proxy class call Webservices localhost.axis.Services.class1Service.class1 x = new localhost.axis.services.class1service.class1ServiceLocator () .getclass1service (); //( ((LocalHost.axis.Services.class1service.class1serviceOapbindingstub) x) .SETMAINTAINSESSION (TRUE); system.out.println (x.sayhelloto);}}