我编写了一个返回 5 个值的 Web 服务:
String taskPresentationName_UWL = null;
String taskActivationTime_UWL = null;
String taskPriority_UWL = null;
String taskStatus_UWL = null;
String taskID_UWL = null;
我的情况是我运行一个循环,我想返回一个包含这些值的列表或数组。
因为它现在是代码,所以我只得到 1 行作为答案。例如:
taskPresentationName_test1、taskActivationTime_test1、taskPriority_test1、taskStatus_test1、taskID_test1
但我想返回的答案应该如下所示:
taskPresentationName_test1、taskActivationTime_test1、taskPriority_test1、taskStatus_test1、taskID_test1
taskPresentationName_test2、taskActivationTime_test2、taskPriority_test2、taskStatus_test2、taskID_test2
……
如何将答案返回到列表或 Xml???
我的代码如下
@WebService(name = "getUWLTasks", portName = "getUWLTasksPort", serviceName = "getUWLTasksService", targetNamespace = "http://sap.com/tutorial/testAPI/")
@Stateless
public class getUWLTasks
{
@WebMethod(operationName = "getTasks", exclude = false)
public void getTasks(
@WebParam(name = "taskPresentationName", mode = WebParam.Mode.OUT) Holder<String> taskPresentationName,
@WebParam(name = "taskActivationTime", mode = WebParam.Mode.OUT) Holder<String> taskActivationTime,
@WebParam(name = "taskPriority", mode = WebParam.Mode.OUT) Holder<String> taskPriority,
@WebParam(name = "taskStatus", mode = WebParam.Mode.OUT) Holder<String> taskStatus,
@WebParam(name = "taskID", mode = WebParam.Mode.OUT) Holder<String> taskID) {
String taskPresentationName_UWL = null;
String taskActivationTime_UWL = null;
String taskPriority_UWL = null;
String taskStatus_UWL = null;
String taskID_UWL = null;
try
{
TaskInstanceManager taskInstanceManager = BPMFactory.getTaskInstanceManager();
HashSet<Status> statuses = new HashSet<Status>();
statuses.add(Status.READY);
statuses.add(Status.RESERVED);
statuses.add(Status.IN_PROGRESS);
Set<TaskAbstract> myTasks = taskInstanceManager.getMyTaskAbstracts(statuses);
Iterator<TaskAbstract> taskIter = myTasks.iterator();
while (taskIter.hasNext())
{
TaskAbstract ta = taskIter.next();
//Get the UWL as it appears
java.net.URI taskInstanceId = ta.getId();
URL taskExecutionURL = taskInstanceManager.generateTaskExecutionUrl(taskInstanceId);
TaskDetail taskDetail = taskInstanceManager.getTaskDetail(taskInstanceId);
taskPresentationName_UWL = ta.getPresentationName();
taskActivationTime_UWL = ta.getCreatedTime().toString();
taskPriority_UWL = ta.getPriority().toString();
taskStatus_UWL = ta.getStatus().toString();
taskID_UWL = ta.getId().toString();
taskPresentationName.value = taskPresentationName_UWL;
taskActivationTime.value = taskActivationTime_UWL;
taskPriority.value = taskPriority_UWL;
taskStatus.value = taskStatus_UWL;
taskID.value = taskID_UWL;
}
}
catch (BPMException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}