Axis调用webservice接口例子

public String invokeByAxis(String requestParam,String method) {
String result = "";
Service service = new Service();
String endPoint = "http://******:8088/bsbiam/services/SoapTreasury4A?wsdl";
try {
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endPoint);
call.addParameter("reqMsg", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setOperationName(new QName(endPoint,method));
result = (String) call.invoke(new Object[]{requestParam});
System.out.println("返回值:" + result);
} catch (Exception e) {
System.out.print("WebService请求异常!! ");
e.printStackTrace();
}
return result;

}

备注:

requestParam: xml请求参数

method:请求的方法

reqMsg:方法中的参数

猜你喜欢

转载自www.cnblogs.com/bky-234/p/10008836.html