Webservice client generation method, webservice Client
1. Create a webservice client through eclipse. This function is provided by eclipse and is not described in detail;
2. Run the following code to generate a webservice client based on the wsdl file:
Set HOME = D: \ workspace \ cvte \ ekp \ WebContent \ WEB-INF \ lib
Java-classpath % HOME % \ axis-1.4.jar; % HOME % \ axis-ant.jar; % HOME % \ commons-discovery-0.2.jar; % HOME % \ commons-logging-1.0.4.jar; % HOME % \ jaxrpc. jar; % HOME %\ log4j-1.2.16.jar; % HOME % \ mail. jar; % HOME % \ saaj-api-1.3.jar; % HOME % \ wsdl4j-1.6.2.jar; % HOME % \ mail. jar; org. apache. axis. wsdl. WSDL2Java-p com. landray. kmss. cvte. review. integration. webservice. client. ocs-t-s http://ocs.gz.cvte.cn/WS/SwDeliverBill? Wsdl
Pause
Check whether each jar package exists, the path of the jar package, and the name of the stored package of the client code.
3. directly write the java code for calling. The following code uses AXIS to call webservice.
Service service = new Service (); // create a Service object
String endPoint = "http://ocstestlmk.gz.cvte.cn/WS/SwDeliverBill"; // do you want to remove it here? Wsdl. Otherwise, an error is reported.
// Your WebService URL
QName qName = new QName (endPoint); // create a QName object and drop your endPoint
Call call = service. createCall (qName, "getSYSoftByWorkOrderId"); // create a Call object to lose the QName strength and the method name provided by WebSevice. Here I am sayHello
Call. setTargetEndpointAddress (endPoint); // you must specify the endPoint in the Call instance.
Object invoke = call
. Invoke (new Object [] {"Ki5lkjofj4Fsj3dDSjj3sdji38j6 ",
"Liaomingkai", "QX-SY15031071H "});
System. out. print (invoke );
List outputValues = call. getOutputValues ();
For (Iterator iterator = outputValues. iterator (); iterator. hasNext ();){
Object object = (Object) iterator. next ();
System. out. println (object );
}