我做过的一个例子:
import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import com.yupont.utils.XMLUtil;
public class ServiceTest {
public String callSGCCService(String operationName,String inputXML,String serviceName,String serverContextRoot)
{
StringBuilder result=null;
try {
String endpoint = serverContextRoot+"/services/"+serviceName;
Service service = new Service();// 创建一个服务(service)调用(call)
Call call = (Call)service.createCall();// 通过service创建call对象
call.setTargetEndpointAddress(new java.net.URL(endpoint));// 设置service所在URL
call.setOperationName(new QName("http://service.yupont.com",operationName));
call.setUseSOAPAction(true);
String result1 = (String)call.invoke(new Object[]{inputXML});
System.out.println(result1);
result=new StringBuilder(result1);
result.append("@@@@@");
result.append(XMLUtil.getNodeTxtByNodeName(XMLUtil.strToXML(result1).getRootElement(), "URL"));
}
catch (Exception e)
{
System.err.println(e.toString());
}
return result.toString();
}
}
你可以参考一下