Designer 10.7 | webMethods Service Development Help | Building Java Services | Generating Code a Java Service Can Use to Invoke a Specified Service | Example of Java Code Generated for Invoking a Service
 
Example of Java Code Generated for Invoking a Service
Suppose you have a service that has the following input and output parameters:
Input Parameters
Output Parameters
String
Document
String
String
input1
inDoc
in1
in2
String
Document
String
String
output1
outDoc
out1
out2
The following shows code that Designer generated for the above input and output parameters:
// input
IData input = IDataFactory.create();
IDataCursor inputCursor = input.getCursor();
IDataUtil.put( inputCursor, "input1", "input1" );
 
// inDoc
IData inDoc = IDataFactory.create();
IDataCursor inDocCursor = inDoc.getCursor();
IDataUtil.put( inDocCursor, "in1", "in1" );
IDataUtil.put( inDocCursor, "in2", "in2" );
inDocCursor.destroy();
IDataUtil.put( inputCursor, "inDoc", inDoc );
inputCursor.destroy();
 
// output
IData output = IDataFactory.create();
try{
output = Service.doInvoke( "Folder2.subFolder", "selectedService",
            input );
}catch( Exception e){}
IDataCursor outputCursor = output.getCursor();
String output1 = IDataUtil.getString( outputCursor, "output1" );
 
// outputDoc
IData outputDoc = IDataUtil.getIData( outputCursor, "outputDoc" );
if ( outputDoc != null)
{
IDataCursor outputDocCursor = outputDoc.getCursor();
String out1 = IDataUtil.getString( outputDocCursor, "out1" );
String out2 = IDataUtil.getString( outputDocCursor, "out2" );
outputDocCursor.destroy();
}
outputCursor.destroy();
Related Topics
Generating Code a Java Service Can Use to Invoke a Specified Service
Generating Java Code to Invoke a Service
About the Service Signature
Generating Java Code from Service Input and Output Parameters