import java.net.URL;
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 wsdl
{
public static void main(String[] args)
{
Service service = new Service();
try
{
Call call = (Call)service.createCall();
//webservice服务地址
URL url = new URL("http://135.191.55.219:9080/interface/TestService");
call.setTargetEndpointAddress(url);
//设置方法名称时一并设置命名空间
//call.setOperationName(new QName("http://XXX.com","methodName"));
//设置调用的方法名称
call.setOperationName(new QName("methodName"));
//设置请求参数数据类型RequestInfo是参数名
call.addParameter("RequestInfo", XMLType.SOAP_STRING, ParameterMode.IN);
//设置返回结果数据类型
call.setReturnType(XMLType.SOAP_STRING);
//调用接口
String result = call.invoke(new Object[]{"requestParam"});
System.out.println(result );
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
WebService接口调用
最新推荐文章于 2021-09-22 16:54:49 发布