Need help here. I’m just new to WM java service. I might made some mistakes along the code.
I wanted to create a java service that would spawn a number of threads depending on the number of input parameters, each input will do a server.doThreadInvoke to a certain flow service that will have some processing. During the implementation it keeps on throwing an error execution.
I get to see the logging of the inputParam[0]. (invoked service contains logging). however, I can’t see if it was able to process the inputParam[1] and so on. because I can’t see their process in the logs. My guess is that during the first invocation, inputParam[0]. it was able to successfully invoke the service but after the invocation, there’s some error.
I get a null pointer error at the first loop (it doesn’t reach the second loop) because I’m not seeing “reached this point” in the logs. Is there any step that I’m missing.
Error
java.lang.NullPointerException
at helloFolder.anotherFold.services.ServiceMade(services.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
@Mahesh, I wanted to create a service that would accept an array input. These array input will looped inside the service and each input will spawn a new thread and invoke a service. This way I would be able to asynchronously invoke services, then take the output of each spawned thread and output it as the output of the service.
@Xiaowei Wang, Thank you for this. This solved my problem.
Actually, I have a service that outputs an array of string. Then each string is an input of the invoked service, since the backend of the invoked service might respond for more than a second, invoking the service synchronously for each input string might take me forever(e.g. string might have a length of 50). Then taking the response of each of the invoked service( so that could be a document array of 50 ) for further processing.
E.g. Service Response = inputParam[0] = input_1, inputParam[1]=input_2, inputParam[2]=input_3.
So I need to invoke “helloFolder.anotherFold.services:ServiceMade” 3x asynchronously.
And read some posts from the forum, their talking about service.doThreadInvoke() and getIData(). So I was thinking of using them with some for Loop logic.
hmmm… Do you mean pub.flow:invokeService can invoke other service Asynchronously? The documentation seems to be confusing.
Thank you. I would like to get some suggestions If you could provide. I really wanted to avoid java service if possible.