I am new to the group & webMethods environment. We are using webMethods for the first time in one of our pilot project.
We are developing a utility, which takes a service name as input and the data in an XML format. The Utility constructs the NSName, input IData and Invokes the service by calling Service.doInvoke. IData is a document contains collection of various objects or string.
My job is to construct the appropriate document from the given XML. I can pull the elements and its value from the XML. The document element names are exactly same as XML element names, but I do not know the data type of the document element.
For example: If one of the elements of the document is Date object and the name is TodayDate. The XML has TodayDate element with a value 2006-01-30. I need to convert this to java.util.Date object and assign to the document element, TodayDate… I do not know the element data type of the document; the client is not providing the document info. Is there any way to find what type of input the service takes before invoking the Service.doInvoke. Please help me.
Have you considered not dropping to Java (which seems unnecessary given the info here) and simply using FLOW and built-in services to process the XML into the form you need?
Yes, first we created a Flow service to process the incoming XML. The document is created based on the schema. The incoming XML is converted to document using xmlStringToNode and xmlNodeToDocument (standard flow service libraries). The output from the xmlNodeToDocument is assigned to the referenced document. The following is the structure of the document.
In the flow service we need to create a message stating how many data nodes we received to process. To get the count we used pub.list.sizeOfList service and is returned ‘3’, perfect, next switch statement to identify the appropriate service and mapped the data to an appropriate type and used loop and invoked the service, all went well, team is happy, because this is our first attempt with webMethods.
Now the problem started when we had only one data node, example
The referencing document for the above sample has single data doc but not data doc list, like above three data node sample. Both referencing the same document reference, I think IS decides to use document list or document based on the data node. In single data node case, the sizeOfList is throwing an exception and also we are unable to execute the loop. The Loop and sizeOfList takes string, doc, or object List.
We are unable to find solution to solve the above problem then we decided to use java service that parses the document using JAXP and extracted data node and looped to extract individual data elements. Now we stuck with the data type mapping. We know the service to invoke but not the data type of the individual elements of the data node. So our question is how we can extract the input data type of the service that is not loaded.
Could you please help us, how to make the reference document has data doc list even though the incoming XML has single data node, then we can make use of the developed Flow service. Or how do we extract the input data types of a given service in the Java service code before executing Service.doInvoke.
In the xmlNodeToDocument call specify the appropriate documentTypeName. The document type should specify the expected structure of the XML doc. In the example you detailed, “data” should be a document list. This will indicate to IS that a list is to be created even when only one node is present. Refer to the Built-in Services guide for a description of this. This is a fairly common issue that people new to IS encounter.
It worked after setting the documentTypeName.Thank you for your help.