When I call a service B from service A, the pipeline of service A is available to service B. If input parameter of service B has same name as of pipeline variable. e.g. a variable POHeader exists in service A pipeline before call to service B and the input parameter of service B has same name and structure as POHeader. The variable gets automatically mapped to service B input parameter.
How does webMethods handles this POHeader variable? Are there 2 instances of POHeader in memory or it is just passed by reference?
How does service A pipeline variables made available to service B - separate copy of variables or reference to original variables? If reference to original variables then when we drop the variables in service B, then is only the reference dropped or the original variables are also dropped?
If I have POHeader structure consisting of 25 variables, but the service B requires only 3 of those variables, then what is the best practice -
- to pass complete POHeader structure and let service B extract required 3 parameters or
- to pass only the 3 parameters
One thought I have with respect to option 2 above is passing 3 parameters only will make 3 more variables created in memory and passed as value, thus increasing the memory requirements. Also it will require me to drop these variables after call to service B.
Where as with option 1 the structure will be passed by reference, hence reducing the memory requirement. But the code readability may decrease as another developer will not know the 3 variables actually utilised without going through code / comment (if any).
But with option 2, if tomorrow I need to add one more parameter, then the complete service signature changes and all the dependent services are affected by it.
What is the best practice?