---
title: "axis2客户端开发"
author: "cake513"
date: "2010-07-12T16:58:26Z"
tags: []
categories: ["编程语言"]
slug: "axis2"
draft: false
lastmod: "2010-07-13T10:31:31Z"
id: 710873
url: "https://cake513.iteye.com/blog/710873"
---

```
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
/*web服务方法签名：public String callService(String startTime, String endTime) */

public class ServiceTest {

	public static void main(String[] args) {
		
			String startTime = "2010-05-02";
			String endTime = "2010-05-20";
		
			String serviceSpace="http://service.xcky.com";
			String methodName = "callService";//服务方法名
			String serviceUrl= "http://localhost:8081/axis2/services/xcky?wsdl";
			
			Service service = new Service();
			Call call = null;
			try {
				call = (Call) service.createCall();
				call.setTargetEndpointAddress(new java.net.URL(serviceUrl));
				call.setOperationName(new QName(serviceSpace, methodName1));
				Object[] inargs = new Object[] {startTime,endTime};//参数数组
				String strReturn =  (String)call.invoke(inargs);
				System.out.println(strReturn);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
}
}
```