java后台调用例子:
public static void main(String[] args) {
String url = "http://192.168.0.119/WebServices.asmx";//SOAP 地址
String namespace="http://tempuri.org/";//namespace名称
String method="method";//方法名称
String parameter=“参数内容”;//方法中的参数(方法中的参数可能为多个,此例子为一个)
callSoapService(url, namespace, method, new Object[]{parameter});//new Object[]{parameter}为传入的参数,多个参数为:new Object[]{parameter,parameter2,parameter3......}
}
public static Object callSoapService(String serviceUrl ,String nameSpace,String methodName, Object[] paremateArrs){
String endPoint = serviceUrl;
String actionUrl=nameSpace+methodName;
Object returnObj = null;
try{
Service service = new Service();
Call call = null;
call = (Call)service.createCall();
QName qName = new QName(nameSpace,methodName);
call.setOperationName(qName);
call.setSOAPActionURI(actionUrl);
call.addParameter(new QName(nameSpace,"参数名称"), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);//将参数放入其中,(此例子参数为一个,若参数为多个可以多次call.addParameter......)
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setTargetEndpointAddress(new URL(endPoint));
returnObj = call.invoke(paremateArrs);
}catch(Exception ie){
ie.printStackTrace();
}
System.out.println(returnObj);
return returnObj;
}