0

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();    
      }
   }
}
4

1 に答える 1

0

私は単純なWSを作成し、すべてがあなたの望むように機能します

@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)
          {
             taskPresentationName.value = new String[]{"a1", "a2"}; 
             taskActivationTime.value = new String[]{"b1", "b2"};
             taskPriority.value = new String[]{"c1", "c2"};
          }  

応答が含まれています

 <taskPresentationName>a1</taskPresentationName>
 <taskPresentationName>a2</taskPresentationName>
     <taskActivationTime>b1</taskActivationTime>
 <taskActivationTime>b2</taskActivationTime>
     <taskPriority>c1</taskPriority>
 <taskPriority>c2</taskPriority>  

編集

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Task 
{
   String taskPresentationName_UWL;
   //...
   String taskID_UWL;

   // getters, setters
}  

タスク

@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Tasks
{
   @XmlElement
   private List<Task> tasks = new ArrayList<Task>(); 

   public List<Task> getTasks()
   {
      return tasks;
   }
}  

web-method

@WebMethod(operationName = "getTasks", exclude = false)
@WebResult(name = "tasks")
public Tasks getTasks() {  
//...  
}
于 2012-08-28T14:05:44.743 に答える