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.
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.
Bob/Mark
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)
–>mainframeID2
–>mainframeID3
–>mainframeID4
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.
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?