java客户端调用webservice的简单例子

package client;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.rpc.ParameterMode;

public class AxisClient {

 public static void main(String[] args) throws Exception {
  Service service = new Service();
  Call call = (Call) service.createCall();

  call.setTargetEndpointAddress("http://localhost/axis/services/ValidationWS?wsdl");

  // 设置操作名
  call.setOperationName("check");
  // 设置入口参数
  call.addParameter("op1", XMLType.XSD_STRING, ParameterMode.IN);
  call.setReturnType(XMLType.XSD_STRING);
  String loginid = "testid";
  // 调用服务
  System.out.println("THIS ID IS "+ call.invoke(new Object[] { loginid }) + "!");

 }
}

 

你可能感兴趣的:(java,apache,xml,webservice)