使用Java调用第三方webservice接口
public static Object saveBidderInfo(String tranplatformcode,String json){
try {
Service service = new Service();
Call call = (Call) service.createCall();
//调用接口的地址:“http://112.124.15.189:31001/user?wsdl”
call.setTargetEndpointAddress("http://112.124.15.189:31001/user?wsdl");
//saveBidderInfo 接口的名称
call.setOperationName("http://exter.chxtec.com/"), "saveBidderInfo"));
//接口里的参数 XSD_STRING是参数的类型(参数名称有时不能与接口里的相同,可以写arg0 arg1....)
call.addParameter("tranplatformcode", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.addParameter("json", org.apache.axis.encoding.XMLType.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
//返回的类型
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
Object result=(Object)call.invoke(new Object[]{tranplatformcode,json});
//返回数据
return result;
} catch (Exception e) {
//打印异常,并返回null
System.err.println(e.toString());
return null;
}
}
注意
-1.调用接口的地址
-2.调用接口的名称
-3.调用接口的参数
-4.http://exter.chxtec.com/ 是接口的命名空间