Get input and output parameter names of a given service

Sure, you need to implement the service in IS first, and then invoke it through WM API from anywhere.

Thanks for your help. I could successfully get the “primitive” input fields however I’m having difficulty if I have documents/documentReferenes (or these nested). How could I get an input with all of the fields including the nested documents/refs?

public static final void nstest(IData pipeline) throws ServiceException {
	
		// pipeline
		IDataCursor pipelineCursor = pipeline.getCursor();
			String	nodeName = IDataUtil.getString( pipelineCursor, "nodeName" );
		pipelineCursor.destroy();
		
		List<String> fieldNames = new ArrayList<String>();
		
		Namespace ns = Namespace.current();
		NSNode nsNode = ns.getNode(nodeName);
		if (nsNode instanceof NSService) {
			NSService nsService = (NSService) nsNode;
			NSSignature signature = nsService.getSignature();
			NSRecord input = signature.getInput();
			NSField[] fields = input.getFields();
			for (final NSField field : fields) {
			final String 		FieldName 		= field.getName();
				final Integer 	FieldDimension 	= Integer.valueOf(field.getDimensions());
				final Integer 	FieldType 		= Integer.valueOf(field.getType());
				
				String format = String.format("FieldName: %s; FieldDimension: %d; FieldType: %d", FieldName, FieldDimension, FieldType);
				fieldNames.add(format);
				
				if (FieldType.equals(Integer.valueOf(2))) {
					// Get Document fields...
				}
				
				if (FieldType.equals(Integer.valueOf(4))) {
					// Get referenced document fields...
				}
			}
		}
		
		// pipeline
		IDataCursor pipelineCursor_1 = pipeline.getCursor();
		IDataUtil.put( pipelineCursor_1, "input", fieldNames.toArray() );
		pipelineCursor_1.destroy();			
	}

I couldn’t find any method for NSField that would return me the underlying document fields or referenced document node names.

After you get the NSField object, you need to check its class.
If it’s a string or object field, the class is NSField, you already know how to parse it.
If it’s a document field, the class is NSRecord, then you can continually parse it as what you did to input/output signature(by calling getFields method).
If it’s a document reference field, the class is NSRecordRef, then you can get the referenced document name by calling getTargetName method.


for (final NSField field : fields) {  
    String fieldClassName = field.getClass().toString();
    if (fieldClassName .equals("com.wm.lang.ns.NSRecord")){
        NSRecord docField = (NSRecord)field;
        .... ....
    }else .... ....
}

Hi Horvath and Wang,
Greetings !!

I am trying to solve a similar problem. I am writing a webMethods service which determines input and output signature of a particular service and tries to capture the pipeline values of those inputs.

Could you please share the entire code if you can?

Thanks,
Shashank.

Go through this thread properly you have the source code.