官方網頁:http://ws.apache.org/axis/
Axis2服務端參照:
所需Jar包:
axis.jar
commons-logging-1.0.4.jar
commons-discovery-0.2.jar
jaxrpc.jar
saaj.jar
wsdl4j-1.5.1.jar
log4j-1.2.8.jar
代碼如下:
package samples.clients;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
public class StockQuoteServiceClient {
public static void main(String[] args) {
try {
String endpointURL = "http://localhost:8080/Axis2Web/services/StockQuoteService?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpointURL));
call.setOperationName(new QName("http://quickstart.samples/xsd", "getPrice"));
call.addParameter("symbol", XMLType.SOAP_STRING, ParameterMode.IN);
call.setReturnType(XMLType.SOAP_STRING);
String ret = (String) call.invoke(new Object[] { "ShenBin" });
System.out.println(ret);
} catch (Exception e) {
}
}
}