How to call wM flow service from a java service

Hi,

Could anybody pls let me know how to call a flow service (built in/custom developed) from a java service in wM Developer? Also if you can mention any wM documentation that would also help.

Thanks for your help!
Joy

See Developers Guide (Chapt 14. Developing Client Code).

Developer will automatically generate the following code
(Tools–>GenerateCode…)

===========java service that calls a flow service (generated by Developer)
// input
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put( inputCursor, “flowInString”, “flowInString” );
inputCursor.destroy();

// output
IData output = IDataFactory.create();
try{
output = Service.doInvoke( “ladson_java2flow”, “flowCallee”, input );
}catch( Exception e){}
IDataCursor outputCursor = output.getCursor();
String flowOutString = IDataUtil.getString( outputCursor, “flowOutString” );
outputCursor.destroy();

===============hand coded java service that calls a flow service
String javaInString;
String javaOutString;

String folder = “ladson_java2flow”;
String service = “flowCallee”;

//get java input
IDataCursor idcPipeline = pipeline.getCursor();
if(idcPipeline.first(“javaInString”))
{
javaInString = (String)idcPipeline.getValue();
}
else
{
System.out.println(“genCSVFileLoop: javaInString is not in pipeline!”);
throw new ServiceException(“javaInString is not in pipeline!”);
}

//setup input for flow service
String flowInString = javaInString;
IDataCursor idcPipe = serviceIn.getCursor();
idcPipe.first(“flowInString”);
idcPipe.delete();
idcPipe.insertBefore(“flowInString”, flowInString);
idcPipe.destroy();

//call flow service
try
{
serviceOut = invokeISService(folder, service, serviceIn);
}
catch (Exception e)
{
throw new ServiceException(e);
}

//return output value
String flowOutString;
IDataCursor idcOutput = serviceOut.getCursor();
if(idcOutput.first(“flowOutString”))
{
flowOutString = (String)idcOutput.getValue();
}
else
{
System.out.println(“java2flow: flowOutString is not in pipeline!”);
throw new ServiceException(“flowOutString is not in returned pipeline!”);
}
System.out.println(“flowOutString=”+flowOutString);

1 Like

Create a subclass of Service class and use the doinvoke() methods to invoke any flow service from the java code. Refer to JAVA API for more details…can find it in the following path \webMethods6\Developer\doc\api\Java\

1 Like

Is there a way to do exactly this from standalone Java programe i.e. you a standard piece of java code that you write and wants have it executed which then invokes service in WM IS with inputs provided from the service? Basically to invoke IS service from outside the WM IS.

Thanks,

Ashish

See Developers Guide (Chapt 14. Developing Client Code).

(Tools–>GenerateCode–>For calling this service from a client–>java language

Developer will automatically generate the following code

/*

  • This class has been automatically generated by the webMethods Developer™.

*/

import java.io.;
import java.util.Vector;
import com.wm.util.Table;
import com.wm.data.
;
import com.wm.util.coder.IDataCodable;
import com.wm.app.b2b.util.GenUtil;
import com.wm.app.b2b.client.Context;
import com.wm.app.b2b.client.ServiceException;

public class sayHelloFromFlow{

<????????150 lines deleted for brevity ????????????????????>
public static IData invoke(
    Context context, IData inputDocument)
    throws IOException, ServiceException
{
     IData out = context.invoke("ladson_junk", "sayHelloFromFlow", inputDocument);
     IData outputDocument = out;
     return outputDocument;
}

}

Thats great. Thanks it’s working now.

This is really great.

I was facing some issues with the java service.
This snippet of the forum has really helped me to sort the problem.

Thanks it is working.