0
我寫了返回5個值webservice的多個值:JAX web服務與JAXB返回使用循環
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,t askActivationTime_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();
}
}
}
答案被更新 – Ilya
我的問題是,我一直在使用,因爲我的某些環境限制的只有一個類,以達到預期的效果開發 – user1630426
使用字符串[]代替持有人 –
Ilya