MWS Task API to retrieve TaskData in non Task Packages.

hi All,

We have a scenario where we have to use data present - in TaskData object of MWS Tasks in Generic portlets which are present in non Task packages.

At present, to get TaskData, we are using getTask() method from webservice: http://host:port/services/bizPolicy/task?WSDL.

This getTask() method returns the contents of taskdata as a HashMap and we are getting custom data as shown below:

Hashtable taskBusinessData = this.getGetTask().getResult().getTaskData();
Hashtable customData = (Hashtable)taskBusinessData.get("customData");
String strValue1 = customData.get('customStrData1');
String strValue2 = customData.get('customStrData2');

Is there any better procedure where we can use existing MWS Task API in Generic portlets (in non Task Packages), to get TaskData?

We tried using TaskContentProviderExtended, TaskContentProvider and ItaskPortType class, but these classess has methods to get only TaskInfo object.

Kind regards,
Raja sekhar Kintali

The more common practice is to have the task data operated on by business logic contained in the Task Web Application. No other application will have access to the custom task data java classes.

However, you can directly invoke the web service support using in-proc apis shown in the following example.

Hope this helps.
–mark

import java.util.HashMap;
import java.util.Map;

import com.webmethods.portal.system.PortalSystem;
import com.webmethods.portal.bizPolicy.IContext;
import com.webmethods.portal.bizPolicy.IContextProvider;
import com.webmethods.portal.bizPolicy.command.ICommandManager;
import com.webmethods.portal.bizPolicy.command.ICommandBean;
import com.webmethods.portal.bizPolicy.command.task.webservice;

//get the current user's context
IContextProvider cp = (IContextProvider) PortalSystem.getContextProvider();
IContext ctx = cp.acquireContext(true);

//get the command manager
ICommandManager cm = (ICommandManager) PortalSystem.getCommandProvider();

//get the webservice version of the GetTask command that uses generic non-typed classes
GetTaskWS getTaskWS = (GetTaskWS) cm.getCommand(ctx, GetTaskWS.COMMAND_NAME);

//set the invocation properties (loosely typed)... Same inputs as the web service version
Map props = new HashMap();
props.put("user", <userid>);
props.put("taskID", <taskID>);
props.put("includeTaskData", true);
ICommandBean cb = getTaskWS.createBean(ctx, props);

//invoke
Map results = getTaskWS.invoke(ctx, cb);

Hi Mark,

We have tried to implement this code in our environment for getting the task data. It seems the ‘invoke (IContext, ICommandBean)’ method is not defined in the type of object GetTaskWS and hence the compilation error is thrown in designer as ““The method invoke (IContext, ICommandBean) is undefined for the type GetTaskWS

Hi Kaleeswaran,

You can try to extend TaskInboxSearchContentProvider.

   public class MyTaskSearchProvider extends TaskInboxSearchContentProvider {

  //constructor 
   public MyTaskSearchProvider(){
          m_searchQuery = new MySearchQuery();
   }

  public com.webmethods.caf.faces.data.task.impl.TaskData getTaskData() {
    return (com.webmethods.caf.faces.data.task.impl.TaskData) getValue(PROPERTY_TASKDATA);
  }

  //inner class
  public class MySearchQuery extends InboxSearchQuery {
      private TaskSearchQueryTerm myQueryTerm= null;

    public TaskSearchQueryTerm getMyQueryTerm() {
      if (myQueryTerm== null) {
        myQueryTerm= new TaskSearchQueryTerm();
      }
      return myQueryTerm;
    }

//....
}

I hope this small sample will help you.

br,
Vlad

The GetTaskWS might not be in your projects classpath. So we can try for the more generic interfaces. Instead of

GetTaskWS getTaskWS = (GetTaskWS) cm.getCommand(ctx, GetTaskWS.COMMAND_NAME); 

please try this

import com.webmethods.portal.bizPolicy.command.ICommand;

ICommand getTaskWS = cm.getCommand(ctx, "getTask_ws"); 

hi Mark,

Tried with following code:

ICommand getTaskWS = cm.getCommand(ctx, “getTask_ws”);
Map results = getTaskWS.invoke(ctx, cb);

Compilation error is coming at line 2 with message “invoke method is not defined”. I suspect that invoke method is not defined in ICommand or it’s super classes (in webMethods 7.1.2)

Kind regards,
Raja sekhar Kintali

Sorry. It should have been ‘handle’ instead.

hi Mark,

Tried using methods available in ICommand interface to get Task info and Task data.

I am successfully able to get and update Task info and Task data using this API. Thanks for your help. :slight_smile:

Kind regards,
Raja sekhar Kintali

Hi All,

I wanted test the code here but not sure where are these JAR file. Can any one tell me where I can get these jar files.

Thanks

Hi All

Is there any way I can use these apis in a normal Dynamic webProject in the webMethods Designer by just importing few jars?? I dont want to use webservices as I am going to deploy my new webapp in MWS server itself.
Please help!!

Thanks
Sajeevan

If you can then keep the task project in build path of this webProject and you should be able to use all of the task API methods().