I am a beginner is OSB. I am working on a task that has to count the no.of .parameters from the consumer(Soap UI) in the proxy service. And if the parameter is lesser than 4 an error has to be thrown else it should be routed to another business service. Anyone worked on such scenario before?

Can you please post the definition of function xf:getParameter() as well.
Seems like the way you have written the below two functions, <LNIGeneratorRequest> will always have fixed number of child elements. You will need to create the child elements only if the parameter data is present:
SOmething like this: