java 代码
- package test;
- import javax.xml.namespace.QName;
- import org.apache.axis.client.Call;
- import org.apache.axis.client.Service;
- public class Test {
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- String method = "GetServerList";
- Service service = new Service();
- Call call = (Call) service.createCall();
- call.setTargetEndpointAddress(new java.net.URL("http://hostname/BABLDWebService/Service.asmx"));
- call.setOperationName(new QName("http://tempuri.org/",method));
- call.setUseSOAPAction(true);
- call.setReturnType(org.apache.axis.encoding.XMLType.SOAP_ARRAY);
- call.setSOAPActionURI("http://tempuri.org/GetServerList");
- Object[] k = (Object[])call.invoke(new Object[]{});
- for(int i=0;i<k.length;i++)
- System.out.println(k[i]);
- }
- }
本文提供了一个使用Java调用WebService服务的示例代码。通过Apache Axis库创建客户端调用远程HTTP服务,并获取服务器列表数据。
186

被折叠的 条评论
为什么被折叠?



