The first time with Java tune Webervice, online read a lot of blogs, can use a few, integrated several blogs, finally successfully called.
Package com.casco.action;
Import Org.apache.axis.client.Call;
Import Org.apache.axis.client.Service;
Import Javax.xml.namespace.QName;
public class Syncprojectdata {
public void Syncproject (String projectno)
{
}
public static void Main (string[] args) {
try {
String endpoint = "XXXX?WSDL";
Directly referencing a remote WSDL file
Here are the routines.
Service service = new service ();
Call Call Service.createcall ();
Call.settargetendpointaddress (endpoint);
Call.setoperationname (New QName ("http://tempuri.org/", "getprojectbycondition")); Interface name described in WSDL
Call.addparameter (New QName ("http://tempuri.org/", "condition"),
Org.apache.axis.encoding.XMLType.XSD_STRING, Javax.xml.rpc.ParameterMode.IN);//Parameters of the interface
Call.setusesoapaction (TRUE);
Call.setreturntype (Org.apache.axis.encoding.XMLType.SOAP_STRING); Returns the type of the parameter
Call.setsoapactionuri ("Http://tempuri.org/GetProjectByCondition"); This also should be noted is to add the method to call Getprojectbycondition, otherwise it will error
String temp = "A0117032"; The value of the parameter
String result = (string) call.invoke (new object[] {temp});
Pass a parameter to the method, and call the method
SYSTEM.OUT.PRINTLN ("result is" + result);
} catch (Exception e) {
System.err.println (E.tostring ());
}
}
}
Java call Webservcie, self-test available