The example in this article describes the Java call to WebService interface method. Share to everyone for your reference. Specifically as follows:
Here is the reference method add, the code is as follows:
Copy Code code as follows:
public static void Addtest () {
Try ... {
Integer i = 1;
Integer j = 2;
WebService URL
String Service_url = "Http://localhost:4079/ws/Service.asmx";
Service service = new service ();
Call call = (call) Service.createcall ();
Call.settargetendpointaddress (New Java.net.URL (Service_url));
Set the method to invoke
Call.setoperationname (New QName ("Http://www.jb51.net/T", "ADD"));
The parameters required by the method
Call.addparameter ("A", Org.apache.axis.encoding.XMLType.XSD_INT,
Javax.xml.rpc.ParameterMode.IN);
Call.addparameter ("B", Org.apache.axis.encoding.XMLType.XSD_INT,
Javax.xml.rpc.ParameterMode.IN);
Return value type of method
Call.setreturntype (Org.apache.axis.encoding.XMLType.XSD_INT);
Call.setusesoapaction (TRUE);
Call.setsoapactionuri ("Http://www.jb51.net/Add");
Call this method
Integer res = (integer) call.invoke (
New object[] ... {
I, J
}
);
SYSTEM.OUT.PRINTLN ("Result:" + res.tostring ());
catch (Exception e) ... {
System.err.println (e);
}
}
Run, results returned: Result:3
I hope this article will help you with your Java programming.