Custom Java Service Retrieve document values from pipeline

Hello. I may be missing something really easy but I am having trouble with a custom java service I am writing.

I want to write a custom Java service that retrieves a number of items off the pipe line and returns a string list.

So far I have this working fine if the values on the pipeline are not in a document.

Basically my service does the following:

Inputs: Pipeline variable name,
size of output list

Pipeline has something like this on it.

Notice the document contains enumerated string elements with basically the same name.

I would pass into my service the following key value

I would then run a loop for the number of items in that document along the line of the following using the getString function.

IDataUtil.getString(cursor, “MainframeIDs/MainframeID”+ i)

The getString function does not work. The value is always null.

How do I access items inside of a document that is on the pipeline?
Any help would be greatly appreciated.

Have you tried using the next() function on the Document cursor? This allows you to iterate over all items in the document. Than you can test each item for the name (getName) and verify if it matched the name you are looking for… With getValue you can check whether it has the value you expected.

Check out the IS API in your developer/docs directory. It will show you the light. Do note however that follow any getName and getValue with a getLast. This is some aweful bug in wm. If you don’t it messes up your document in memory.


Have you tried doing what you need using FLOW?


I don’t understand the structure of your input document, so this may be a little off.

Assuming that you are starting with an input document that looks like this:

and want to produce and output string list like this
, you should be able to use Flow (as Rob suggests) to loop over the input documentList and use a MAP statement with an appendToStringList transformer to do what you need.


Thanks for all your help. I actually figured out how to access document elements in a Java service.

Looping in Flow wouldn’t work for me because the document isn’t a “document list”. It was a single document with multiple elements like this (sorry, no idea how to include pictures like you):

docMainframeIDs (document name)
–>mainframeID1 (element in document)

I had to get each element out of that document and add it to a string list. See how the elements have similar names that only differ by an integer? I had originally done what I needed to do with 4 map statements with a appendToStringList transformer in each map step. It was ugly and I had to do this in a number of different places for different documents. I decided to create a generic Java service that would take any document of similar format and output a string list. Took a while but I got it working.

If anyone is interested in seeing what I did, let me know. Perhaps you could see some improvements I could add.

Thanks again,

Hi Matt,

If you could give a brief decription about how you accessed a Document’s Variable through a Java Service would help me a lot as I’m looking for some solution to get Document’s Field Names so that I can map the Querried Data to Document whose Name is given as input to the Java Service.


I’m not sure about the latest webMethods releases, but in 4.6 there used to be a Service called “pub.web:queryDocument” in WmPublic. Doesn’t this Service do exactly what you are looking for?

Cheers, Lanzelot