Total Pageviews

2017/09/08

[webMethods] How to invoke a Flow Service from a Java Service

Problem
如何在 Java Service 中,呼叫一個 Flow Service?

How-To
按照不同的情境 (synchronous 或 asynchronous),與有參數或無參數,需呼叫不同的 API,JavaDoc 如下:
JavaDoc for asynchronous


JavaDoc for synchronous


Examples:
1. Asynchronous and DO NOT have input parameter
    Session session = Service.getSession(); 
    Service.doThreadInvoke("test.work", "Test_Flow", session, IDataFactory.create());


2. Asynchronous and HAVE input parameter (s)
    Session session = Service.getSession(); 
    
    IData input = IDataFactory.create();
        
    IDataCursor inputCursor = input.getCursor();
    IDataUtil.put(inputCursor, "input", " test test ");
    inputCursor.destroy();
    
    Service.doThreadInvoke("test.work", "Test_Flow", session, input);


3. Synchronous and DO NOT have input parameter
    Service.doInvoke("test.work", "Test_Flow", IDataFactory.create());


4. Synchronous and HAVE input parameter (s)
    IData input = IDataFactory.create();
        
    IDataCursor inputCursor = input.getCursor();
    IDataUtil.put(inputCursor, "input", " test test ");
    inputCursor.destroy();
    
    Service.doInvoke("test.work", "Test_Flow", input);

No comments: